How to use the netlify-cms-lib-util.unsentRequest.withBody 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
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-bitbucket / src / API.js View on Github external
deleteFile = (path, message, { branch = this.branch } = {}) => {
    const body = new FormData();
    body.append('files', path);
    body.append('branch', branch);
    if (message) {
      body.append('message', message);
    }
    if (this.commitAuthor) {
      const { name, email } = this.commitAuthor;
      body.append('author', `${name} <${email}>`);
    }
    return flow([unsentRequest.withMethod('POST'), unsentRequest.withBody(body), this.request])(
      `${this.repoURL}/src`,
    );
  };
}