Category view + detail
This commit is contained in:
parent
5ebd10cd3a
commit
aaedcec4a6
8 changed files with 3360 additions and 1599 deletions
53
services/request.tsx
Normal file
53
services/request.tsx
Normal file
|
@ -0,0 +1,53 @@
|
|||
import axios from 'axios';
|
||||
|
||||
const API_URL = 'https://kliko.maartenvr98.nl/api/v1/';
|
||||
const CONFIG = {
|
||||
timeout: 3000,
|
||||
};
|
||||
|
||||
export class Request {
|
||||
/**
|
||||
* Send GET request to API
|
||||
*
|
||||
* @param url
|
||||
* @param headers
|
||||
* @returns {Promise<AxiosResponse<any>>}
|
||||
*/
|
||||
static get(url: string, headers = {}) {
|
||||
return axios.get(API_URL + url, {
|
||||
...CONFIG,
|
||||
...headers,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send POST request to API
|
||||
*
|
||||
* @param url
|
||||
* @param body
|
||||
* @param headers
|
||||
* @returns {Promise<AxiosResponse<any>>}
|
||||
*/
|
||||
static post(url: string, body = {}, headers = {}) {
|
||||
return axios.post(API_URL + url, body, {
|
||||
...CONFIG,
|
||||
...headers,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send PUT request to API
|
||||
*
|
||||
* @param url
|
||||
* @param body
|
||||
* @param headers
|
||||
* @returns {Promise<AxiosResponse<any>>}
|
||||
*/
|
||||
static put(url: string, body = {}, headers = {}) {
|
||||
return axios.put(API_URL + url, body, {
|
||||
...CONFIG,
|
||||
...headers,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue