Merge pull request #14135 from alissonfabiano/af/fix-content-type-post-request
Fixed bug that when sending data by Post
This commit is contained in:
@@ -105,14 +105,18 @@ export class TechInsightsClient implements TechInsightsApi {
|
||||
const url = await this.discoveryApi.getBaseUrl('tech-insights');
|
||||
const { token } = await this.identityApi.getCredentials();
|
||||
|
||||
const request = new Request(`${url}${path}`, init);
|
||||
if (!request.headers.has('content-type')) {
|
||||
request.headers.set('content-type', 'application/json');
|
||||
}
|
||||
if (token && !request.headers.has('authorization')) {
|
||||
request.headers.set('authorization', `Bearer ${token}`);
|
||||
const headers: HeadersInit = new Headers(init?.headers);
|
||||
if (!headers.has('content-type'))
|
||||
headers.set('content-type', 'application/json');
|
||||
if (token && !headers.has('authorization')) {
|
||||
headers.set('authorization', `Bearer ${token}`);
|
||||
}
|
||||
|
||||
const request = new Request(`${url}${path}`, {
|
||||
...init,
|
||||
headers,
|
||||
});
|
||||
|
||||
return fetch(request).then(async response => {
|
||||
if (!response.ok) {
|
||||
throw await ResponseError.fromResponse(response);
|
||||
|
||||
Reference in New Issue
Block a user