-
Hi how I can send a custom response and message on status 400, export const (req, res) {
// external api call
const response = await axios.post(...)
//handle response
res.status(200).json(response.data)
// if has an error
res.status(400).json(response.data)
} on front-end, I don't receive the payload data if not status 200 try {
let response = await.post(...)
console.log(response.data)
} catch (error) {
console.log(error) // i cant get the payload passed here if not status 200
} |
Beta Was this translation helpful? Give feedback.
Answered by
vassbence
Mar 22, 2020
Replies: 1 comment
-
Here is some help from the axios docs, but honestly you are better off not using axios for simple use-cases like the one you provided. On the front-end next.js already polyfills fetch and in the lambdas you can use node-fetch. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
blackmo18
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is some help from the axios docs, but honestly you are better off not using axios for simple use-cases like the one you provided. On the front-end next.js already polyfills fetch and in the lambdas you can use node-fetch.