How to use the netlify-cms-lib-util.responseParser 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 / API.js View on Github external
requestText = req =>
    flow([
      unsentRequest.withDefaultHeaders({ 'Content-Type': 'text/plain' }),
      this.request,
      then(responseParser({ format: 'text' })),
      p => p.catch(err => Promise.reject(new APIError(err.message, null, 'BitBucket'))),
    ])(req);
github netlify / netlify-cms / packages / netlify-cms-backend-bitbucket / src / API.js View on Github external
readFile = async (path, sha, { parseText = true } = {}) => {
    const cacheKey = parseText ? `bb.${sha}` : `bb.${sha}.blob`;
    const cachedFile = sha ? await localForage.getItem(cacheKey) : null;
    if (cachedFile) {
      return cachedFile;
    }
    const node = await this.branchCommitSha();
    const result = await this.request({
      url: `${this.repoURL}/src/${node}/${path}`,
      cache: 'no-store',
    }).then(parseText ? responseParser({ format: 'text' }) : responseParser({ format: 'blob' }));
    if (sha) {
      localForage.setItem(cacheKey, result);
    }
    return result;
  };