mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
@@ -5,14 +5,19 @@ type Options = {
|
||||
url: string;
|
||||
method: Method;
|
||||
body: Record<string, any> | string | null;
|
||||
headers: Record<string, string>;
|
||||
headers?: { header: string; value: string }[] | null;
|
||||
};
|
||||
|
||||
export default defineOperationApi<Options>({
|
||||
id: 'request',
|
||||
|
||||
handler: async ({ url, method, body, headers }) => {
|
||||
const result = await axios({ url, method, data: body, headers });
|
||||
const customHeaders = headers?.reduce((acc, { header, value }) => {
|
||||
acc[header] = value;
|
||||
return acc;
|
||||
}, {} as Record<string, string>);
|
||||
|
||||
const result = await axios({ url, method, data: body, headers: customHeaders });
|
||||
|
||||
return { status: result.status, statusText: result.statusText, headers: result.headers, data: result.data };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user