How to use the react-on-rails.authenticityHeaders function in react-on-rails

To help you get started, we’ve selected a few react-on-rails 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 shakacode / react-webpack-rails-tutorial / client / app / bundles / comments / components / SimpleCommentScreen / SimpleCommentScreen.jsx View on Github external
handleCommentSubmit(comment) {
    this.setState({ isSaving: true });

    const requestConfig = {
      responseType: 'json',
      headers: ReactOnRails.authenticityHeaders(),
    };

    return (
      request
        .post('comments.json', { comment }, requestConfig)
        .then(() => {
          const { $$comments } = this.state;
          const $$comment = Immutable.fromJS(comment);

          this.setState({
            $$comments: $$comments.unshift($$comment),
            submitCommentError: null,
            isSaving: false,
          });
        })
        .catch(error => {
github shakacode / react-webpack-rails-tutorial / client / app / libs / requestsManager.js View on Github external
submitEntity(entity) {
    return request({
      method: 'POST',
      url: API_URL,
      responseType: 'json',
      headers: ReactOnRails.authenticityHeaders(),
      data: entity,
    });
  },

react-on-rails

react-on-rails JavaScript for react_on_rails Ruby gem

MIT
Latest version published 4 months ago

Package Health Score

89 / 100
Full package analysis