Fixed xhr
This commit is contained in:
parent
b9cf282d32
commit
ffaf8558b2
@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/js-utilities",
|
"name": "@ztimson/js-utilities",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"description": "JavaScript Utility library",
|
"description": "JavaScript Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"private": false,
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.zakscode.com/ztimson/js-utilities"
|
"url": "https://git.zakscode.com/ztimson/js-utilities"
|
||||||
|
@ -45,7 +45,7 @@ export class XHR<T> {
|
|||||||
return fetch(`${this.baseUrl}${href || ''}`.replace(/([^:]\/)\/+/g, '$1'), {
|
return fetch(`${this.baseUrl}${href || ''}`.replace(/([^:]\/)\/+/g, '$1'), {
|
||||||
headers,
|
headers,
|
||||||
method: opts.method || (body ? 'POST' : 'GET'),
|
method: opts.method || (body ? 'POST' : 'GET'),
|
||||||
body: (headers['Content-Type'].startsWith('application/json') && body) ? JSON.stringify(body) : body
|
body: (headers['Content-Type']?.startsWith('application/json') && body) ? JSON.stringify(body) : body
|
||||||
}).then(async resp => {
|
}).then(async resp => {
|
||||||
for(let fn of this.getInterceptors()) {
|
for(let fn of this.getInterceptors()) {
|
||||||
const wait = new Promise(res =>
|
const wait = new Promise(res =>
|
||||||
|
Loading…
Reference in New Issue
Block a user