@usecapsule/user-management-client
Advanced tools
Comparing version 0.18.0-dev.0 to 0.18.0-dev.1
@@ -200,4 +200,4 @@ import axios, { AxiosInstance, AxiosRequestHeaders, AxiosResponseHeaders } from 'axios'; | ||
if (opts?.useFetchAdapter) { | ||
axios.defaults.adapter = function(config: AxiosRequestConfig) { | ||
return fetch(config.baseURL + config.url.substring(1), { | ||
axios.defaults.adapter = async function(config: AxiosRequestConfig): Promise<any> { | ||
const response = await fetch(config.baseURL + config.url.substring(1), { | ||
method: config.method, | ||
@@ -207,14 +207,18 @@ headers: config.headers as HeadersInit, | ||
credentials: config.withCredentials ? 'include' : undefined | ||
}).then(response => | ||
response.text().then(text => ({ | ||
data: text, | ||
status: response.status, | ||
statusText: response.statusText, | ||
headers: response.headers, | ||
config: config, | ||
request: fetch | ||
})) | ||
).catch(function(reason) { | ||
throw reason; | ||
}); | ||
console.log('fetch response:') | ||
console.log(response) | ||
console.log(JSON.stringify(response)) | ||
console.log(response.text()) | ||
console.log(JSON.stringify(response.text())) | ||
console.log(JSON.stringify(response.json())) | ||
const resToReturn = await response.text().then(text => ({ | ||
data: text, | ||
status: response.status, | ||
statusText: response.statusText, | ||
headers: response.headers, | ||
config: config, | ||
request: fetch | ||
})); | ||
return resToReturn; | ||
} as any; | ||
@@ -221,0 +225,0 @@ } |
@@ -434,18 +434,33 @@ "use strict"; | ||
axios_1.default.defaults.adapter = function (config) { | ||
return fetch(config.baseURL + config.url.substring(1), { | ||
method: config.method, | ||
headers: config.headers, | ||
body: config.data, | ||
credentials: config.withCredentials ? 'include' : undefined | ||
}).then(function (response) { | ||
return response.text().then(function (text) { return ({ | ||
data: text, | ||
status: response.status, | ||
statusText: response.statusText, | ||
headers: response.headers, | ||
config: config, | ||
request: fetch | ||
}); }); | ||
}).catch(function (reason) { | ||
throw reason; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, resToReturn; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, fetch(config.baseURL + config.url.substring(1), { | ||
method: config.method, | ||
headers: config.headers, | ||
body: config.data, | ||
credentials: config.withCredentials ? 'include' : undefined | ||
})]; | ||
case 1: | ||
response = _a.sent(); | ||
console.log('fetch response:'); | ||
console.log(response); | ||
console.log(JSON.stringify(response)); | ||
console.log(response.text()); | ||
console.log(JSON.stringify(response.text())); | ||
console.log(JSON.stringify(response.json())); | ||
return [4 /*yield*/, response.text().then(function (text) { return ({ | ||
data: text, | ||
status: response.status, | ||
statusText: response.statusText, | ||
headers: response.headers, | ||
config: config, | ||
request: fetch | ||
}); })]; | ||
case 2: | ||
resToReturn = _a.sent(); | ||
return [2 /*return*/, resToReturn]; | ||
} | ||
}); | ||
}); | ||
@@ -452,0 +467,0 @@ }; |
{ | ||
"name": "@usecapsule/user-management-client", | ||
"version": "0.18.0-dev.0", | ||
"version": "0.18.0-dev.1", | ||
"main": "dist/client.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/client.d.ts", |
Sorry, the diff of this file is not supported yet
79264
1528