How to use the netlify-cms-lib-util.unsentRequest.withHeaders function in netlify-cms-lib-util

To help you get started, we’ve selected a few netlify-cms-lib-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netlify / netlify-cms / packages / netlify-cms-backend-bitbucket / src / implementation.js View on Github external
then(async res => {
        if (res.status === 401) {
          const json = await res.json().catch(() => null);
          if (json && json.type === 'error' && /^access token expired/i.test(json.error.message)) {
            const newToken = await this.getRefreshedAccessToken();
            const reqWithNewToken = unsentRequest.withHeaders(
              { Authorization: `Bearer ${newToken}` },
              req,
            );
            return unsentRequest.performRequest(reqWithNewToken);
          }
        }
        return res;
      }),
    ])(req);
github netlify / netlify-cms / packages / netlify-cms-backend-bitbucket / src / implementation.js View on Github external
apiRequestFunction = async req => {
    const token = this.refreshedTokenPromise ? await this.refreshedTokenPromise : this.token;
    return flow([
      unsentRequest.withHeaders({ Authorization: `Bearer ${token}` }),
      unsentRequest.performRequest,
      then(async res => {
        if (res.status === 401) {
          const json = await res.json().catch(() => null);
          if (json && json.type === 'error' && /^access token expired/i.test(json.error.message)) {
            const newToken = await this.getRefreshedAccessToken();
            const reqWithNewToken = unsentRequest.withHeaders(
              { Authorization: `Bearer ${newToken}` },
              req,
            );
            return unsentRequest.performRequest(reqWithNewToken);
          }
        }
        return res;
      }),
    ])(req);
github netlify / netlify-cms / packages / netlify-cms-backend-git-gateway / src / GitLabAPI.js View on Github external
authenticateRequest = async req =>
    unsentRequest.withHeaders(
      {
        Authorization: `Bearer ${await this.tokenPromise()}`,
      },
      req,
    );
github netlify / netlify-cms / packages / netlify-cms-backend-git-gateway / src / implementation.js View on Github external
      .then(token => unsentRequest.withHeaders({ Authorization: `Bearer ${token}` }, req))
      .then(unsentRequest.performRequest);
github netlify / netlify-cms / packages / netlify-cms-backend-gitlab / src / API.js View on Github external
withAuthorizationHeaders = req =>
    unsentRequest.withHeaders(this.token ? { Authorization: `Bearer ${this.token}` } : {}, req);