Use the correct verbs in the API

This commit is contained in:
Alex Ling
2020-12-14 12:49:56 +00:00
parent 4f6df5b9a3
commit d33b45233a
5 changed files with 64 additions and 42 deletions

View File

@@ -220,14 +220,18 @@ const saveProgress = (idx, cb) => {
console.log('saving progress', idx);
const url = `${base_url}api/progress/${tid}/${idx}?${$.param({eid: eid})}`;
$.post(url)
.then(data => {
if (data.error) throw new Error(data.error);
$.ajax({
method: 'PUT',
url: url,
dataType: 'json'
})
.done(data => {
if (data.error)
alert('danger', data.error);
if (cb) cb();
})
.catch(e => {
console.error(e);
alert('danger', e);
.fail((jqXHR, status) => {
alert('danger', `Error: [${jqXHR.status}] ${jqXHR.statusText}`);
});
}
};