api.js 580 B

1234567891011121314151617181920212223
  1. import axios from 'axios';
  2. //const csrfParamName = document.querySelector('meta[name="csrf-param"]').content;
  3. //const csrfToken = document.querySelector('meta[name="csrf-token"]').content;
  4. const instance = axios.create({
  5. baseURL: 'http://localhost:3000/api/v1',
  6. timeout: 3000,
  7. responseType: 'json',
  8. headers: {post: {'Content-Type': 'application/json'}},
  9. //xsrfHeaderName: csrfParamName,
  10. });
  11. export const Pokemon = {
  12. index: async () => instance.get('/pokemon'),
  13. get: async id => instance.get(`/pokemon/${id}`),
  14. };
  15. const API = {
  16. Pokemon,
  17. };
  18. export default API;