Skip to content

Api gateway#60 - #83

Open
guysa-AMG wants to merge 6 commits into
lindelwa122:mainfrom
guysa-AMG:apiGateway#60
Open

Api gateway#60#83
guysa-AMG wants to merge 6 commits into
lindelwa122:mainfrom
guysa-AMG:apiGateway#60

Conversation

@guysa-AMG

@guysa-AMG guysa-AMG commented Oct 18, 2025

Copy link
Copy Markdown

closes #60
This pull request adds a set of helper functions that handle REST API requests using the native fetch API. Each function supports both JSON and text responses and includes callbacks for handling success, errors, and cleanup.

The methods implemented are:

Get – performs GET requests and returns parsed data.

Post – sends POST requests with headers and body.

Put – updates resources using PUT requests.

Patch – partially updates resources.

Delete – deletes resources.

Each function consistently uses handlerCallback, errorCallback, and finalCallback to give full control over response handling and error management.

Unit tests were written using Jest. The tests rely on mocked responses to simulate different outcomes, including success and error cases. These tests confirm that each method behaves as expected, properly resolves data, and triggers the right callbacks.

@lindelwa122

Copy link
Copy Markdown
Owner

@guysa-AMG thanks for all the efforts, I will make you a PR as hacktoberfest-accepted. I will review it properly tomorrow and give you feedback. Just one thing to mention, it's preferable if the method names are in lowercase, just to be consistent with the styling.

@guysa-AMG

Copy link
Copy Markdown
Author

morning .i have refactored the method names to lowercase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apiGateway

2 participants