bubble up all fetch errors in the http helper
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
	"name": "@ztimson/utils",
 | 
			
		||||
	"version": "0.20.1",
 | 
			
		||||
	"version": "0.20.2",
 | 
			
		||||
	"description": "Utility library",
 | 
			
		||||
	"author": "Zak Timson",
 | 
			
		||||
	"license": "MIT",
 | 
			
		||||
 
 | 
			
		||||
@@ -75,6 +75,7 @@ export class Http {
 | 
			
		||||
 | 
			
		||||
		// Send request
 | 
			
		||||
		return new PromiseProgress((res, rej, prog) => {
 | 
			
		||||
			try {
 | 
			
		||||
				fetch(url, {
 | 
			
		||||
					headers,
 | 
			
		||||
					method: opts.method || (opts.body ? 'POST' : 'GET'),
 | 
			
		||||
@@ -100,6 +101,7 @@ export class Http {
 | 
			
		||||
									push();
 | 
			
		||||
								}).catch((error: any) => controller.error(error));
 | 
			
		||||
							}
 | 
			
		||||
 | 
			
		||||
							push();
 | 
			
		||||
						}
 | 
			
		||||
					});
 | 
			
		||||
@@ -115,7 +117,10 @@ export class Http {
 | 
			
		||||
 | 
			
		||||
					if(resp.ok) res(resp);
 | 
			
		||||
					else rej(resp);
 | 
			
		||||
			})
 | 
			
		||||
				}).catch(err => rej(err));
 | 
			
		||||
			} catch(err) {
 | 
			
		||||
				rej(err);
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user