add example client
This commit is contained in:
18
example_client/svelte-client/src/api.js
Normal file
18
example_client/svelte-client/src/api.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
};
|
Reference in New Issue
Block a user