fix: HTTP Request tool - do not error on missing headers (#10044)

This commit is contained in:
Michael Kret 2024-07-15 13:28:46 +03:00 committed by GitHub
parent b42f652f1b
commit 04b62e0398
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -49,7 +49,8 @@ const genericCredentialRequest = async (ctx: IExecuteFunctions, itemIndex: numbe
const headerAuth = await ctx.getCredentials('httpHeaderAuth', itemIndex);
return async (options: IHttpRequestOptions) => {
options.headers![headerAuth.name as string] = headerAuth.value;
if (!options.headers) options.headers = {};
options.headers[headerAuth.name as string] = headerAuth.value;
return await ctx.helpers.httpRequest(options);
};
}
@ -58,9 +59,7 @@ const genericCredentialRequest = async (ctx: IExecuteFunctions, itemIndex: numbe
const queryAuth = await ctx.getCredentials('httpQueryAuth', itemIndex);
return async (options: IHttpRequestOptions) => {
if (!options.qs) {
options.qs = {};
}
if (!options.qs) options.qs = {};
options.qs[queryAuth.name as string] = queryAuth.value;
return await ctx.helpers.httpRequest(options);
};