don't lose comment if it failed to create

This commit is contained in:
Théo Zimmermann 2014-12-19 15:19:55 +01:00
parent 8918c4a186
commit bba91b3f93

View File

@ -90,7 +90,13 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
var create = function(tid, data) { var create = function(tid, data) {
var deferred = Q.defer(); var deferred = Q.defer();
curl("POST", endpoint + "/new?" + qs({uri: tid || location}), JSON.stringify(data), curl("POST", endpoint + "/new?" + qs({uri: tid || location}), JSON.stringify(data),
function (rv) { deferred.resolve(JSON.parse(rv.body)); }); function (rv) {
if (rv.status === 201) {
deferred.resolve(JSON.parse(rv.body));
} else {
deferred.reject(rv.body);
}
});
return deferred.promise; return deferred.promise;
}; };