This code aborts the request after 10 ms:
const controller = new AbortController();
const signal = controller.signal;
fetch('https://jsonplaceholder.typicode.com/todos/1', {
signal
})
.then(response => response.json())
.then(data => {
console.log('Data:', data);
})
.catch(err => {
console.log(err)
if (err.name === 'AbortError')....
});
setTimeout(() => {
controller.abort();
}, 10);
Output :
DOMException: signal is aborted without reason
Question:
If it says “without a reason,” is it possible to supply a reason?
Because otherwise, the message is a bit strange, as if I could supply a reason but didn’t.