Closed jusper-dk closed 6 years ago
In this case the request is coming back as a valid as a 404 isn't an error? This line should handle that as ok should be false for a 404. Can you share more of your code?
For now, if file does not exist, the following code outputs an object with 'odata.error' property like if it was a content of the file: web.getFileByServerRelativeUrl().getJSON() .then(result => console.log(result))
But I expect that it rejects the promise. Here, the result should be an alert 'An error has occurred' is case the file does not exist: web.getFileByServerRelativeUrl().getJSON() .then(result => console.log(result)) .catch(result => alert('An error has occurred'))
Otherwise, how can I detect that the file does not exist - make a separate request?
I didn't look closely enough. Those shorthand methods don't check the request status before returning the result. Will have a look at updating. Thanks for reporting it.
Fixed this in #796, will be part of next release. Thanks!
Thank you! When will the release become available?
web.getFileByServerRelativeUrl().getJSON() always resolves promise even if the file does not exist.
Expected behavior: reject a result.