Open john-dalsgaard opened 9 years ago
@john-dalsgaard, I am facing the similar issue, did you get any work around?
@SPorwal No, unfortunately not. So right now I just get "an error" and reacts the same way to all errors. I have looked at other APIs to do the REST calls - but so far I have not changed anything.
I guess we could fix it ourselves and send a pull request :-)
Hi
I am trying to use this API for retrieving and updating data. If I do a collection.create and it fails, the code returns to the "error:" section. However, I have found no way to get a handle on the error message itself...
This is my code:
'x' seemt to always be undefined. The output from the above code is:
[INFO] [iphone, 8.0, 192.168.42.38] sendPostRequest response: {"action":"login","dataType":"Credentials","data":{"user":"john@dalsgaard-data.dk","password":"dfdf","version":"1.0.0"}} [ERROR] [iphone, 8.0, 192.168.42.38] sendPostRequest error: {"collection":[{"action":"login","dataType":"Credentials","data":{"user":"john@dalsgaard-data.dk","password":"dfdf","version":"1.0.0"}}],"i ndex":0} [INFO] [iphone, 8.0, 192.168.42.38] remoteLoginError: result.success=undefined, result.error=undefined [ERROR] [iphone, 8.0, 192.168.42.38] result={"action":"login","dataType":"Credentials","data":{"user":"john@dalsgaard-data.dk","password":"dfdf","version":"1.0.0"}} [ERROR] [iphone, 8.0, 192.168.42.38] [REST API] CREATE ERROR: [ERROR] [iphone, 8.0, 192.168.42.38] { "success": false, "status": "error", "code": 403, "error": "HTTP error", "responseText": "{\"success\":false,\"error\":{\"id\":\"2\",\"message\":\"Ugyldig bruger (john@dalsgaard-data.dk) eller kodeord\"}}", "responseJSON": { "success": false, "error": { "id": "2", "message": "Ugyldig bruger (john@dalsgaard-data.dk) eller kodeord" } } }
So basically, I don't get the error back in my code. However, I can see it from the REST API as I have enabled debugging.
If I use a "fetch" instead and this error handling:
Then I get the valid error message (though only the message in localized language - and not a code to make it easier to check programmatically). Am I doing something wrong? - or does the API not support returning the "real" error to my code?
Thanks in advance.
Edited 23 October - more complete code examples...
/John