Files
chatservice_concept/example_client/svelte-client/src/api.js
2025-05-25 13:03:16 -04:00

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;
};