devour-client
devour-client copied to clipboard
Receiving: undefined is not an object (evaluating 'source.pointer')
I'm trying to have devour (v2.0.7) receive following response in an RN app:
{
"errors":[
{
"title":"Authentication failed",
"detail":"Invalid username and/or password",
"code":"101",
"status":"400"
}
]
}
but, I'm seeing the following error:
undefined is not an object (evaluating 'source.pointer')
- node_modules/devour-client/lib/middleware/json-api/res-errors.js:46:13 in errorKey
- node_modules/devour-client/lib/middleware/json-api/res-errors.js:24:24 in buildErrors
- ... 10 more stack frames from framework internals
I'm new to JSON API, so looking at the docs (http://jsonapi.org/format/#error-objects) I noticed it said an error object MAY have one or more attributes, instead of MUST as used elsewhere. So just wondering if this is still correct?
Otherwise, looking at that code, maybe it's worth checking if source is present as well?
function errorKey(index, source) {
if (!source || source.pointer == null) {
return index;
}
return source.pointer.split('/').pop();
}
Env
Devour 2.0.7 RN 0.50.3