Skip to content

Commit

Permalink
remove _http response field
Browse files Browse the repository at this point in the history
  • Loading branch information
shuowu committed Jun 21, 2022
1 parent d6ed88c commit a67f4c9
Show file tree
Hide file tree
Showing 20 changed files with 23 additions and 295 deletions.
15 changes: 2 additions & 13 deletions docs/myaccount/classes/BaseTransaction.md

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

17 changes: 1 addition & 16 deletions docs/myaccount/classes/EmailChallengeTransaction.md

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

17 changes: 1 addition & 16 deletions docs/myaccount/classes/EmailStatusTransaction.md

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

17 changes: 1 addition & 16 deletions docs/myaccount/classes/EmailTransaction.md

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

17 changes: 1 addition & 16 deletions docs/myaccount/classes/PhoneTransaction.md

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

17 changes: 1 addition & 16 deletions docs/myaccount/classes/ProfileSchemaTransaction.md

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

17 changes: 1 addition & 16 deletions docs/myaccount/classes/ProfileTransaction.md

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

21 changes: 1 addition & 20 deletions lib/http/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export function httpRequest(sdk: OktaAuthHttpInterface, options: RequestOptions)
res = resp.responseText;
if (res && isString(res)) {
res = JSON.parse(res);
// Deprecated: this logic may cause confliction, use "_http" field instead
// Remove in the next major version - OKTA-485317
if (res && typeof res === 'object' && !res.headers) {
if (Array.isArray(res)) {
res.forEach(item => {
Expand Down Expand Up @@ -104,24 +102,7 @@ export function httpRequest(sdk: OktaAuthHttpInterface, options: RequestOptions)
response: res
});
}

// Attach http related info to response
// Only apply to empty or object response
if (Array.isArray(res)) {
res.forEach(item => {
item._http = {
headers: resp.headers,
status: resp.status
};
});
} else if (!res || typeof res === 'object') {
res = res || {};
res._http = {
headers: resp.headers,
status: resp.status
};
}


return res;
})
.catch(function(resp) {
Expand Down
5 changes: 1 addition & 4 deletions lib/myaccount/transactions/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type TransactionOptions = {
// TODO: move res type to http module
res: {
headers: Record<string, string>;
_http: Record<string, string | object>;
_links?: Record<string, TransactionLink>;
[property: string]: unknown;
};
Expand All @@ -14,17 +13,15 @@ type TransactionOptions = {
export default class BaseTransaction {
// Deprecated
headers?: Record<string, string>;
_http: Record<string, string | object>;

constructor(oktaAuth: OktaAuthInterface, options: TransactionOptions) {
const { res } = options;
const { headers, _http, ...rest } = res;
const { headers, ...rest } = res;

// assign required fields from res
if (headers) {
this.headers = headers;
}
this._http = _http;

// add all rest fields from res
Object.keys(rest).forEach(key => {
Expand Down
Loading

0 comments on commit a67f4c9

Please sign in to comment.