Fixed xhr
All checks were successful
Build / Build NPM Project (push) Successful in 15s
Build / Tag Version (push) Successful in 5s
Build / Publish (push) Successful in 13s

This commit is contained in:
Zakary Timson 2024-02-07 23:14:37 -05:00
parent b9cf282d32
commit ffaf8558b2
2 changed files with 3 additions and 2 deletions

View File

@ -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"

View File

@ -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 =>