mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +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,11 +1,11 @@
|
||||
import type { OptionsWithUri } from 'request';
|
||||
|
||||
import type {
|
||||
ICredentialDataDecryptedObject,
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
IHttpRequestMethods,
|
||||
ILoadOptionsFunctions,
|
||||
IRequestOptions,
|
||||
IWebhookFunctions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
@@ -20,7 +20,7 @@ export const removeTrailingSlash = (url: string) => {
|
||||
|
||||
export async function strapiApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body: IDataObject = {},
|
||||
qs: IDataObject = {},
|
||||
@@ -39,7 +39,7 @@ export async function strapiApiRequest(
|
||||
const url = removeTrailingSlash(credentials.url as string);
|
||||
|
||||
try {
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {},
|
||||
method,
|
||||
body,
|
||||
@@ -47,7 +47,7 @@ export async function strapiApiRequest(
|
||||
uri: uri || credentials.apiVersion === 'v4' ? `${url}/api${resource}` : `${url}${resource}`,
|
||||
json: true,
|
||||
qsStringifyOptions: {
|
||||
arrayFormat: 'indice',
|
||||
arrayFormat: 'indices',
|
||||
},
|
||||
};
|
||||
if (Object.keys(headers).length !== 0) {
|
||||
@@ -74,7 +74,7 @@ export async function getToken(
|
||||
|
||||
const url = removeTrailingSlash(credentials.url as string);
|
||||
|
||||
let options = {} as OptionsWithUri;
|
||||
let options = {} as IRequestOptions;
|
||||
options = {
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
@@ -92,7 +92,7 @@ export async function getToken(
|
||||
|
||||
export async function strapiApiRequestAllItems(
|
||||
this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body: IDataObject = {},
|
||||
query: IDataObject = {},
|
||||
|
||||
Reference in New Issue
Block a user