Skip to content

Commit

Permalink
oops
Browse files Browse the repository at this point in the history
  • Loading branch information
Icaruk committed Sep 2, 2021
1 parent f4e82b3 commit 5e3625b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const {response} = dame.post(url, body, config);
- **checkIsError** `function<boolean>`: Function that will receive the status code (`number`) and must return `boolean`. Default `isError = !(code >= 200 && < 300)`.
- Any option that fits on [request](https://nodejs.org/api/https.html#https_https_request_url_options_callback) or [fetch](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch).
- **maxRedirects** `number`: Max redirects to follow. Default 20. Use 0 to disable redirects.
- **responseType** `"arraybuffer" | "stream" | "json" | "text"`: **Browser only**. Default `"json"`. Type of the data that the server will respond with.



Expand Down
18 changes: 9 additions & 9 deletions utils/requestWeb.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ module.exports = function requestWeb({

if (contentTypeLow.startsWith("application/json")) {

const json = await response.json();
data = json;
// const json = await response.json();
// data = json;
if (!config.responseType) config.responseType = "json";

} else if (contentTypeLow.startsWith("text")) {
Expand All @@ -128,13 +128,13 @@ module.exports = function requestWeb({
};


// switch ( (config.responseType || "").toLowerCase() ) {
// case "json": data = await response.json(); break;
// case "text": data = await response.text(); break;
// case "arraybuffer": data = await response.arrayBuffer(); break;
// case "blob": data = await response.blob(); break;
// // case "stream": data = await response.blob(); break;
// };
switch ( (config.responseType || "").toLowerCase() ) {
case "json": data = await response.json(); break;
case "text": data = await response.text(); break;
case "arraybuffer": data = await response.arrayBuffer(); break;
case "blob": data = await response.blob(); break;
// case "stream": data = await response.blob(); break;
};

} catch (err) {};

Expand Down

0 comments on commit 5e3625b

Please sign in to comment.