I'm newbie here and learning full-stack development. When I typed anything in the chat, I got axios error.
I checked my backend and it showed error code 429.
I think it is the problem from api-communicator.ts but I am not sure what I should fix it. I would appreciate any help or suggestions.
import axios from 'axios';
export const loginUser = async (email: string, password: string) => {
const res = await axios.post("/user/login", { email, password });
if (res.status !== 200) {
throw new Error("Unable to login");
}
const data = await res.data;
return data;
};
export const checkAuthStatus = async () => {
const res = await axios.get("/user/auth-status");
if (res.status !== 200) {
throw new Error("Unable to authenticate");
}
const data = await res.data;
return data;
};
export const sendChatRequest = async (message: string) => {
const res = await axios.post("/chat/new", { message });
if (res.status !== 200) {
throw new Error("Unable to send chat");
}
const data = await res.data;
return data;
};