Incluindo lista de marcas de carro do backend

This commit is contained in:
Matheus Albino Brunhara
2022-05-28 16:26:45 -05:00
parent 34c08df016
commit efba742455
6 changed files with 197 additions and 52 deletions

25
src/services/api/cars.ts Normal file
View File

@@ -0,0 +1,25 @@
import instance from './api';
import carsRoutes from '../../constants/routes/carsRoutes';
import { AxiosRequestHeaders } from 'axios';
import LocalStorage from '../../LocalStorage';
let token: string;
let header: AxiosRequestHeaders;
function updateHeader() {
token = LocalStorage.getToken();
header = {
"Accept": 'application/json',
"Content-Type": 'application/json',
"Authorization": 'Bearer ' + token
}
}
export async function list() {
updateHeader();
const response = await instance.get(carsRoutes.list.url, { headers: header });
return response.data;
}