You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
My backend returns a 201 status code with an empty response and location header after a new user is created. According to the specs that should be enough (easier explanation).
If I rewrite following code with the ember-ajax addon:
this.get('ajax').post('user/create',{data: JSON.stringify(data),contentType: 'application/json'}).then(()=>{//location header is only available by the this.get('ajax').raw function, so just print something...console.log('user has been created!')}).catch(error=>{alert(error.payload.errorMessage);});
After a new user has successfully been created, the catch is called! Is there something I should change or should I consider this a ember-ajax bug?
The text was updated successfully, but these errors were encountered:
a) return 204 No content status, that way Ember will not try to parse response body which causes an error
b) return valid JSON body (even empty object, but not an empty string), so that Ember can parse the response without an error.
This was actually just about configuring jQuery correctly to prevent
parsing the response as JSON. Setting the `dataType` to `text` does this
correctly.
Closes#315
This issue is related with Can't use .then() on ember-ajax's Promise after code 200.
My backend returns a 201 status code with an empty response and location header after a new user is created. According to the specs that should be enough (easier explanation).
With plain jQuery you can use the success callback, if you leave the "dataType" unsetted. So following ajax call works fine:
If I rewrite following code with the ember-ajax addon:
After a new user has successfully been created, the
catch
is called! Is there something I should change or should I consider this a ember-ajax bug?The text was updated successfully, but these errors were encountered: