fix header parameter in ts fetch

This commit is contained in:
wing328 2016-10-16 15:27:11 +08:00
parent dee2dd8d36
commit 5a5d3fd5e5
4 changed files with 13 additions and 13 deletions

View File

@ -102,16 +102,16 @@ export const {{classname}}FetchParamCreactor = {
fetchOptions.body = JSON.stringify(params["{{paramName}}"] || {});
}{{/bodyParam}}
{{/hasBodyParam}}
{{#hasHeaderParam}}
{{#hasHeaderParams}}
fetchOptions.headers = {{#supportsES6}}Object.{{/supportsES6}}assign({ {{#headerParams}}
"{{baseName}}": params.{{paramName}},{{/headerParams}}
}, contentTypeHeader);
{{/hasHeaderParam}}
{{^hasHeaderParam}}
{{/hasHeaderParams}}
{{^hasHeaderParams}}
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
{{/hasHeaderParam}}
{{/hasHeaderParams}}
return {
url: url.format(urlObj),
options: fetchOptions,

View File

@ -144,9 +144,9 @@ export const PetApiFetchParamCreactor = {
let fetchOptions: RequestInit = { method: "DELETE" };
let contentTypeHeader: Dictionary<string>;
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
fetchOptions.headers = assign({
"api_key": params.apiKey,
}, contentTypeHeader);
return {
url: url.format(urlObj),
options: fetchOptions,

View File

@ -143,9 +143,9 @@ export const PetApiFetchParamCreactor = {
let fetchOptions: RequestInit = { method: "DELETE" };
let contentTypeHeader: Dictionary<string>;
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
fetchOptions.headers = Object.assign({
"api_key": params.apiKey,
}, contentTypeHeader);
return {
url: url.format(urlObj),
options: fetchOptions,

View File

@ -144,9 +144,9 @@ export const PetApiFetchParamCreactor = {
let fetchOptions: RequestInit = { method: "DELETE" };
let contentTypeHeader: Dictionary<string>;
if (contentTypeHeader) {
fetchOptions.headers = contentTypeHeader;
}
fetchOptions.headers = assign({
"api_key": params.apiKey,
}, contentTypeHeader);
return {
url: url.format(urlObj),
options: fetchOptions,