PHP Classes

File: frontend/src/services/api.ts

Recommend this page to a friend!
  Classes of Edward Paul   Task List   frontend/src/services/api.ts   Download  
File: frontend/src/services/api.ts
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Task List
Manage and share a list of tasks
Author: By
Last change:
Date: 5 days ago
Size: 416 bytes
 

Contents

Class file image Download
import axios from 'axios'; const API_URL = process.env.NEXT_PUBLIC_API_URL; const api = axios.create({ baseURL: API_URL, headers: { 'Content-Type': 'application/json', }, }); api.interceptors.request.use((config) => { const token = localStorage.getItem('token'); if (token) { config.headers.Authorization = `Bearer ${token}`; } return config; }); export default api;