Skip to content

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