18 lines
594 B
JavaScript
18 lines
594 B
JavaScript
import axios from 'axios';
|
|
|
|
const API_BASE_URL = 'http://localhost:3000';
|
|
|
|
export const login = async (username, password) => {
|
|
const response = await axios.post(`${API_BASE_URL}/login`, { username, password });
|
|
return response.data;
|
|
};
|
|
|
|
export const fetchMessages = async () => {
|
|
const response = await axios.get(`${API_BASE_URL}/messages`, { withCredentials: true });
|
|
return response.data;
|
|
};
|
|
|
|
export const createMessage = async (body) => {
|
|
const response = await axios.post(`${API_BASE_URL}/messages/new`, { body }, { withCredentials: true});
|
|
return response.data;
|
|
}; |