We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8436443 commit 3edc3ceCopy full SHA for 3edc3ce
packages/netlify-cms-lib-util/src/API.ts
@@ -116,6 +116,20 @@ export async function requestWithBackoff(
116
}
117
118
119
+type HeaderObj = Record<string, string>
120
+
121
+type HeaderConfig = {
122
+ headers?: HeaderObj,
123
+ token?: string
124
+}
125
+async function constructRequestHeaders(headerConfig: HeaderConfig) {
126
+ const { token, headers } = headerConfig
127
+ const baseHeaders: HeaderObj = {'Content-Type': 'application/json; charset=utf-8', ...headers}
128
+ if (token) {
129
+ baseHeaders['Authorization'] = `token ${token}`
130
+ }
131
+ return Promise.resolve(baseHeaders)
132
133
export async function readFile(
134
id: string | null | undefined,
135
fetchContent: () => Promise<string | Blob>,
0 commit comments