question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Anyway to get error message which is returned by server

See original GitHub issue

Hi there, i am trying to use mande. Is there any way to catch the error is given from server. For an example:

 try {
          const response = await registerApi.post({
            email: this.email,
            password: this.password,
            passwordConfirmed: this.passwordRepeat,
          })

          resolve(response)
        } catch (error) {
          console.log('ServerError', error)
          reject(error)
        }

registerApi is a mande instance. The server returns for me i this case 422 (Unprocessable Entity) and an error message. So how can i show this error message? console.log('ServerError', error) shows ServerError Error: Unprocessable Entity. Thank you in advance

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
koficoudcommented, Apr 27, 2022

@johannesronaldsson You can access to the data using: error.body

try {
  const login = await api.post(apiUri, credentials);
} catch (error) {
  console.error(error.body)
}
0reactions
buenyaminyilmazcommented, Aug 8, 2022

Hi there, i will just test it out. i switched to axios, because i was in hurry

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Troubleshoot Common HTTP Error Codes
This guide focuses on identifying and troubleshooting the most commonly encountered HTTP error codes, i.e. 4xx and 5xx status codes, ...
Read more >
fetch api get error messages from server rather than generic ...
when it fetches and it's an error (500), its message is the generic "Internal Server Error". how do I get the 'some error'...
Read more >
A Complete Guide and List of HTTP Status Codes
A complete list of HTTP status codes with explaination of what they are, why they occur and what you can do to fix...
Read more >
How To Troubleshoot Common HTTP Error Codes
How To Troubleshoot Common HTTP Error Codes ? · Try reloading the URL by pressing F5 key. · Restart all your network equipments...
Read more >
500 Internal Server Error - HTTP - MDN Web Docs - Mozilla
This error response is a generic "catch-all" response. Usually, this indicates the server cannot find a better 5xx error code to response.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found