Pass down client custom headers to native (#6556)

This commit is contained in:
Elias Nahum 2022-08-09 13:29:51 -04:00 committed by GitHub
parent 99ccf52132
commit f55976a2c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 3 deletions

View file

@ -256,6 +256,17 @@ export default class ClientBase {
requestOptions.timeoutInterval = options.timeoutInterval;
}
if (options.headers) {
if (requestOptions.headers) {
requestOptions.headers = {
...requestOptions.headers,
...options.headers,
};
} else {
requestOptions.headers = options.headers;
}
}
let response: ClientResponse;
try {
response = await request!(url, requestOptions);

View file

@ -169,7 +169,12 @@ const ClientUsers = (superclass: any) => class extends superclass {
const {data} = await this.doFetch(
`${this.getUsersRoute()}/login`,
{method: 'post', body},
{
method: 'post',
body,
headers: {'Cache-Control': 'no-store'},
},
false,
);
return data;
@ -341,14 +346,21 @@ const ClientUsers = (superclass: any) => class extends superclass {
getSessions = async (userId: string) => {
return this.doFetch(
`${this.getUserRoute(userId)}/sessions`,
{method: 'get'},
{
method: 'get',
headers: {'Cache-Control': 'no-store'},
},
);
};
checkUserMfa = async (loginId: string) => {
return this.doFetch(
`${this.getUsersRoute()}/mfa`,
{method: 'post', body: {login_id: loginId}},
{
method: 'post',
body: {login_id: loginId},
headers: {'Cache-Control': 'no-store'},
},
);
};

View file

@ -8,6 +8,7 @@ type ClientOptions = {
method?: string;
noRetry?: boolean;
timeoutInterval?: number;
headers?: Record<string, any>;
};
interface ClientErrorProps extends Error {