UNPKG

contentful-management

Version:
22 lines (19 loc) 843 B
import endpoints from './endpoints/index.js'; const makeRequest = async ({ axiosInstance, entityType, action: actionInput, params, payload, headers, userAgent, }) => { // `delete` is a reserved keyword. Therefore, the methods are called `del`. const action = actionInput === 'delete' ? 'del' : actionInput; const endpoint = // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore endpoints[entityType]?.[action]; if (endpoint === undefined) { throw new Error('Unknown endpoint'); } return await endpoint(axiosInstance, params, payload, { ...headers, // overwrite the userAgent with the one passed in the request ...(userAgent ? { 'X-Contentful-User-Agent': userAgent } : {}), }); }; export { makeRequest }; //# sourceMappingURL=make-request.js.map