Skip to content
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

response.data.errmsg #7

Open
JasonDuquain opened this issue Jun 1, 2019 · 1 comment
Open

response.data.errmsg #7

JasonDuquain opened this issue Jun 1, 2019 · 1 comment

Comments

@JasonDuquain
Copy link

JasonDuquain commented Jun 1, 2019

On line 32 there is a conditional that starts with:

if (!response.data.errmsg)

I think this is supposed to be:

if (!response.data.error)

I tried to cause an error with both and only the 2nd one looked like it console logged the output. I looked at the axios docs and could not find anything with response.data.errmsg

@shoesandsocks
Copy link

shoesandsocks commented Jul 9, 2019

I noticed the same thing and also addressed it by modifying the check on the response to look for data.error. Then, while testing something else, I did get back a data.errmsg! In my case, when I had a basic error like a missing required-field, I got back a full response object with data.error and all the other usual keys... but when I got submitted signup with a duplicate key (by mistake), I got back a MongoError with an entirely different shape:

{driver: true, name: "MongoError", index: 0, code: 11000, errmsg: "E11000 duplicate key error collection: test.users index: email_1 dup key: { : null }"}

I suppose the best practice is to check for both.

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

No branches or pull requests

2 participants