nukosuke / rails-react-template

react_on_rails Isomorphic-Single-Page-Application template
http://nukosuke.hatenablog.jp/entry/rails/react_on_rails
Apache License 2.0
4 stars 3 forks source link

wrap fetch API with common headers #10

Open nukosuke opened 7 years ago

nukosuke commented 7 years ago
import 'isomorphic-fetch';
import ReactOnRails from 'react-on-rails';

fetch(API_URL, {
  method: method,
  headers: ReactOnRails.authenticityHeaders({
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  }),
  body: JSON.stringify(...),
  credentials: 'same-origin',
});