Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
bump version for backwards compatibility with v2
Browse files Browse the repository at this point in the history
  • Loading branch information
taylordowns2000 committed Feb 3, 2021
1 parent e83d272 commit fca7b95
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
16 changes: 7 additions & 9 deletions lib/Adaptor.js
Expand Up @@ -121,8 +121,8 @@ function execute(...operations) {
};
}

var Cookie = _toughCookie.default.Cookie;
var cookiejar = new _toughCookie.default.CookieJar();
var Cookie = _toughCookie.default.Cookie;
axios.interceptors.request.use(config => {
cookiejar === null || cookiejar === void 0 ? void 0 : cookiejar.getCookies(config.url, (err, cookies) => {
config.headers.cookie = cookies === null || cookies === void 0 ? void 0 : cookies.join('; ');
Expand Down Expand Up @@ -164,16 +164,14 @@ function handleResponse(state, response) {
params: response.config
});
if (error) throw error;
const backCompatibleResponse = { ...response,
const compatibleResp = { ...response,
httpStatus: response.status,
message: response.statusText
};
const standardDataResponse = { ...backCompatibleResponse,
data: (0, _Utils.tryJson)(backCompatibleResponse.data)
message: response.statusText,
data: (0, _Utils.tryJson)(response.data)
};
const responseWithCookies = handleCookies(standardDataResponse);
return { ...(0, _languageCommon.composeNextState)(state, responseWithCookies.data),
response: responseWithCookies
const respWithCookies = handleCookies(compatibleResp);
return { ...(0, _languageCommon.composeNextState)(state, respWithCookies.data),
response: respWithCookies
};
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@openfn/language-http",
"version": "3.1.1",
"version": "3.1.2",
"description": "An HTTP request language package for use with Open Function",
"homepage": "https://docs.openfn.org",
"repository": {
Expand Down
16 changes: 6 additions & 10 deletions src/Adaptor.js
Expand Up @@ -45,8 +45,8 @@ export function execute(...operations) {
};
}

var Cookie = tough.Cookie;
var cookiejar = new tough.CookieJar();
var Cookie = tough.Cookie;

axios.interceptors.request.use(config => {
cookiejar?.getCookies(config.url, (err, cookies) => {
Expand Down Expand Up @@ -95,22 +95,18 @@ function handleResponse(state, response) {

if (error) throw error;

const backCompatibleResponse = {
const compatibleResp = {
...response,
httpStatus: response.status,
message: response.statusText,
data: tryJson(response.data),
};

const standardDataResponse = {
...backCompatibleResponse,
data: tryJson(backCompatibleResponse.data),
};

const responseWithCookies = handleCookies(standardDataResponse);
const respWithCookies = handleCookies(compatibleResp);

return {
...composeNextState(state, responseWithCookies.data),
response: responseWithCookies,
...composeNextState(state, respWithCookies.data),
response: respWithCookies,
};
}

Expand Down

0 comments on commit fca7b95

Please sign in to comment.