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

Function constructRequestHeaders

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

Source from the content-addressed store, hash-verified

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

Callers 1

apiRequestFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected