Upload 5.1 and 5.2

This commit is contained in:
Andrew Trieu
2023-06-19 14:39:25 +03:00
parent 26304676f1
commit 714cc5d171
14 changed files with 29615 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import axios from "axios";
const baseUrl = "/api/blogs";
let token = null;
const setToken = (newToken) => {
token = `bearer ${newToken}`;
};
const getAll = async () => {
const request = axios.get(baseUrl);
const response = await request;
return response.data;
};
const create = async (newObject) => {
const config = {
headers: { Authorization: token },
};
const response = await axios.post(baseUrl, newObject, config);
return response.data;
};
const update = async (id, newObject) => {
const request = axios.put(`${baseUrl} /${id}`, newObject);
const response = await request;
return response.data;
};
const blogService = {
setToken,
getAll,
create,
update,
};
export default blogService;