Skip to content

Improved Error Handling in /post Route #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shivangisaraf
Copy link

Refactored the /post route to ensure that if the axios.post() request fails, the API does not attempt to send an undefined response.
Previously, in case of a failure, the data variable would remain undefined due to the use of .catch() within await, and res.send(data) could return undefined, potentially confusing clients.

The axios.post() call is now wrapped inside a proper try-catch block, and response.data is returned only if the request is successful. This prevents the API from sending an undefined or malformed response to the client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant