fix(editor): sending data as query on DELETE method (#3972)

* 🐛 fix sending data as query on DELETE method

* 👕 add type to imports

* 💪 enhance test
This commit is contained in:
Ben Hesseldieck
2022-08-30 11:54:50 +02:00
committed by GitHub
parent c2e97a89f9
commit fc2ff35c41
9 changed files with 89 additions and 115 deletions

View File

@@ -1,10 +1,6 @@
import axios, { AxiosRequestConfig, Method } from 'axios';
import {
IDataObject,
} from 'n8n-workflow';
import {
IRestApiContext,
} from '../Interface';
import { IDataObject } from 'n8n-workflow';
import type { IRestApiContext } from '../Interface';
class ResponseError extends Error {
// The HTTP status code of response
@@ -52,7 +48,7 @@ async function request(config: {method: Method, baseURL: string, endpoint: strin
if (process.env.NODE_ENV !== 'production' && !baseURL.includes('api.n8n.io') ) {
options.withCredentials = true;
}
if (['PATCH', 'POST', 'PUT', 'DELETE'].includes(method)) {
if (['POST', 'PATCH', 'PUT'].includes(method)) {
options.data = data;
} else {
options.params = data;