- Added error handler for XHR when resource is unreachable

This commit is contained in:
Ferdi Koomen 2021-11-16 21:14:22 +01:00
parent d482a5716d
commit 133bd31473
2 changed files with 2 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"name": "openapi-typescript-codegen",
"version": "0.12.1",
"version": "0.12.2",
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
"author": "Ferdi Koomen",
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",

View File

@ -17,6 +17,7 @@ async function sendRequest(
return new Promise<XMLHttpRequest>((resolve, reject) => {
xhr.onload = () => resolve(xhr);
xhr.onabort = () => reject(new Error('The user aborted a request.'));
xhr.onerror = () => reject(new Error('Network error.'));
xhr.send(body || formData);
onCancel(() => xhr.abort());