api.ts 582 B

12345678910111213141516171819202122
  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. export const instance = axios.create({
  5. baseURL: '/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: (): any => instance.get('/pokemon'),
  13. get: (id: number | string): any => instance.get(`/pokemon/${id}`),
  14. };
  15. const API = {
  16. Pokemon,
  17. };
  18. export default API;