mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Add IRequestOptions type to helpers.request for more type safety (no-changelog) (#8563)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import type { OptionsWithUri } from 'request';
|
||||
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
JsonObject,
|
||||
IRequestOptions,
|
||||
IHttpRequestMethods,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function storyblokApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body: IDataObject = {},
|
||||
qs: IDataObject = {},
|
||||
@@ -19,7 +19,7 @@ export async function storyblokApiRequest(
|
||||
) {
|
||||
const authenticationMethod = this.getNodeParameter('source', 0) as string;
|
||||
|
||||
let options: OptionsWithUri = {
|
||||
let options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -32,7 +32,7 @@ export async function storyblokApiRequest(
|
||||
|
||||
options = Object.assign({}, options, option);
|
||||
|
||||
if (Object.keys(options.body as IDataObject).length === 0) {
|
||||
if (Object.keys(options.body).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export async function storyblokApiRequest(
|
||||
|
||||
options.uri = `https://api.storyblok.com${resource}`;
|
||||
|
||||
Object.assign(options.qs, { token: credentials.apiKey });
|
||||
Object.assign(options.qs ?? {}, { token: credentials.apiKey });
|
||||
} else {
|
||||
const credentials = await this.getCredentials('storyblokManagementApi');
|
||||
|
||||
@@ -62,7 +62,7 @@ export async function storyblokApiRequest(
|
||||
export async function storyblokApiRequestAllItems(
|
||||
this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
|
||||
Reference in New Issue
Block a user