MCPcopy Create free account
hub / github.com/decaporg/decap-cms / constructRequestHeaders

Function constructRequestHeaders

packages/decap-cms-lib-util/src/API.ts:185–192  ·  view source on GitHub ↗
(headerConfig: HeaderConfig)

Source from the content-addressed store, hash-verified

183}
184
185async function constructRequestHeaders(headerConfig: HeaderConfig) {
186 const { token, headers } = headerConfig;
187 const baseHeaders: HeaderObj = { 'Content-Type': 'application/json; charset=utf-8', ...headers };
188 if (token) {
189 baseHeaders['Authorization'] = `Bearer ${token}`;
190 }
191 return Promise.resolve(baseHeaders);
192}
193
194function handleRequestError(error: FetchError, responseStatus: number, backend: Backend) {
195 throw new APIError(error.message, responseStatus, backend);

Callers 1

apiRequestFunction · 0.85

Calls 1

resolveMethod · 0.80

Tested by

no test coverage detected