How to use the netlify-cms-lib-util.unsentRequest.withMethod 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-gitlab / src / API.js View on Github external
deleteFile = (path, commit_message, options = {}) => {
    const branch = options.branch || this.branch;
    const commitParams = { commit_message, branch };
    if (this.commitAuthor) {
      const { name, email } = this.commitAuthor;
      commitParams.author_name = name;
      commitParams.author_email = email;
    }
    return flow([
      unsentRequest.withMethod('DELETE'),
      // TODO: only send author params if they are defined.
      unsentRequest.withParams(commitParams),
      this.request,
    ])(`${this.repoURL}/repository/files/${encodeURIComponent(path)}`);
  };
}
github netlify / netlify-cms / packages / netlify-cms-backend-bitbucket / src / API.js View on Github external
uploadBlob = (item, { commitMessage, branch = this.branch } = {}) => {
    const contentBlob = get(item, 'fileObj', new Blob([item.raw]));
    const formData = new FormData();
    // Third param is filename header, in case path is `message`, `branch`, etc.
    formData.append(item.path, contentBlob, basename(item.path));
    formData.append('branch', branch);
    if (commitMessage) {
      formData.append('message', commitMessage);
    }
    if (this.commitAuthor) {
      const { name, email } = this.commitAuthor;
      formData.append('author', `${name} <${email}>`);
    }

    return flow([
      unsentRequest.withMethod('POST'),
      unsentRequest.withBody(formData),
      this.request,
      then(() => ({ ...item })),
    ])(`${this.repoURL}/src`);
  };
github netlify / netlify-cms / packages / netlify-cms-backend-gitlab / src / API.js View on Github external
fetchCursor = req =>
    flow([unsentRequest.withMethod('HEAD'), this.request, then(this.getCursor)])(req);
  fetchCursorAndEntries = req =>
github netlify / netlify-cms / packages / netlify-cms-backend-gitlab / src / API.js View on Github external
fetchCursorAndEntries = req =>
    flow([
      unsentRequest.withMethod('GET'),
      this.request,
      p => Promise.all([p.then(this.getCursor), p.then(this.responseToJSON)]),
      then(([cursor, entries]) => ({ cursor, entries })),
    ])(req);
  fetchRelativeCursor = async (cursor, action) => this.fetchCursor(cursor.data.links[action]);