I am trying to calculate the progress of a file upload, so I was using Superagent. I was able to get the progress of the file upload.
Now when a user selects the cancel button, I need to interrupt or cancel the post request. Is there any way to do that. The following is my code:
var file = somefile.pdf
Request.post('
http://posttestserver.com/post.php?dir=example')
.set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
.send(file)
.on('progress', function(e) {
console.log('Progress', e.percent);
})
.end((err, res) => {
console.log(err);
console.log(res);
})
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)