javascript - How do you return a promise? -
i don't understand how return promise. here's i've got far:
post('myprogram.cfm',done) function done(response) { log('done') log(response) } function post(url,callback) { const form = new formdata(document.queryselector('form')) fetch(url, { method: 'post', body: form }).then(then) .then(callback) .catch(fail) function then(response) { return response.json() } function fail(response) { log('fail!') log(response) } }
what is:
const promise = post('myprogram.cfm') promise.done(done)
i think instead of doing then(callback)
, should return something
.
Comments
Post a Comment