Why I got Internal server error and axios error when I typed something in my chat?

42 views Asked by At

I'm newbie here and learning full-stack development. When I typed anything in the chat, I got axios error.

error in browser console

I checked my backend and it showed error code 429.

Error in my backend

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

There are 0 answers