refactor(editor): Apply Prettier (no-changelog) (#4920)
* ⚡ Adjust `format` script * 🔥 Remove exemption for `editor-ui` * 🎨 Prettify * 👕 Fix lint
This commit is contained in:
@@ -19,7 +19,10 @@ class ResponseError extends Error {
|
||||
* @param {number} [httpStatusCode] The HTTP status code the response should have
|
||||
* @param {string} [stack] The stack trace
|
||||
*/
|
||||
constructor (message: string, options: {errorCode?: number, httpStatusCode?: number, stack?: string} = {}) {
|
||||
constructor(
|
||||
message: string,
|
||||
options: { errorCode?: number; httpStatusCode?: number; stack?: string } = {},
|
||||
) {
|
||||
super(message);
|
||||
this.name = 'ResponseError';
|
||||
|
||||
@@ -36,7 +39,13 @@ class ResponseError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
async function request(config: {method: Method, baseURL: string, endpoint: string, headers?: IDataObject, data?: IDataObject}) {
|
||||
async function request(config: {
|
||||
method: Method;
|
||||
baseURL: string;
|
||||
endpoint: string;
|
||||
headers?: IDataObject;
|
||||
data?: IDataObject;
|
||||
}) {
|
||||
const { method, baseURL, endpoint, headers, data } = config;
|
||||
const options: AxiosRequestConfig = {
|
||||
method,
|
||||
@@ -44,7 +53,7 @@ async function request(config: {method: Method, baseURL: string, endpoint: strin
|
||||
baseURL,
|
||||
headers,
|
||||
};
|
||||
if (import.meta.env.NODE_ENV !== 'production' && !baseURL.includes('api.n8n.io') ) {
|
||||
if (import.meta.env.NODE_ENV !== 'production' && !baseURL.includes('api.n8n.io')) {
|
||||
options.withCredentials = true;
|
||||
}
|
||||
if (['POST', 'PATCH', 'PUT'].includes(method)) {
|
||||
@@ -68,14 +77,23 @@ async function request(config: {method: Method, baseURL: string, endpoint: strin
|
||||
throw errorResponseData;
|
||||
}
|
||||
|
||||
throw new ResponseError(errorResponseData.message, {errorCode: errorResponseData.code, httpStatusCode: error.response.status, stack: errorResponseData.stack});
|
||||
throw new ResponseError(errorResponseData.message, {
|
||||
errorCode: errorResponseData.code,
|
||||
httpStatusCode: error.response.status,
|
||||
stack: errorResponseData.stack,
|
||||
});
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function makeRestApiRequest(context: IRestApiContext, method: Method, endpoint: string, data?: IDataObject) {
|
||||
export async function makeRestApiRequest(
|
||||
context: IRestApiContext,
|
||||
method: Method,
|
||||
endpoint: string,
|
||||
data?: IDataObject,
|
||||
) {
|
||||
const response = await request({
|
||||
method,
|
||||
baseURL: context.baseUrl,
|
||||
@@ -88,10 +106,20 @@ export async function makeRestApiRequest(context: IRestApiContext, method: Metho
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function get(baseURL: string, endpoint: string, params?: IDataObject, headers?: IDataObject) {
|
||||
return await request({method: 'GET', baseURL, endpoint, headers, data: params});
|
||||
export async function get(
|
||||
baseURL: string,
|
||||
endpoint: string,
|
||||
params?: IDataObject,
|
||||
headers?: IDataObject,
|
||||
) {
|
||||
return await request({ method: 'GET', baseURL, endpoint, headers, data: params });
|
||||
}
|
||||
|
||||
export async function post(baseURL: string, endpoint: string, params?: IDataObject, headers?: IDataObject) {
|
||||
return await request({method: 'POST', baseURL, endpoint, headers, data: params});
|
||||
export async function post(
|
||||
baseURL: string,
|
||||
endpoint: string,
|
||||
params?: IDataObject,
|
||||
headers?: IDataObject,
|
||||
) {
|
||||
return await request({ method: 'POST', baseURL, endpoint, headers, data: params });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user