I've created a JS webpage that sends the student's authentication information and the ID to take the course, but when I make a POST request to the FastAPI server, it returns a 405 Method Not Allowed error.
Below is the code I tried:
[index.js]
const countia = String(count)
const celestia = String(core)
const dataToSend = {
    stdid: stdid,
    stdpw: stdpw,
    stdmail: stdmail,
    countia: countia,
    celestia: celestia
};
fetch("/api/data", {
    method: "POST",
    headers: {
    'Accept': 'application/json',
    "Content-Type": "application/json"
    },
    body: JSON.stringify(dataToSend)
})
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error(error));
All strings are characters, no problem ( maybe )
[server.py]
class directa(BaseModel):
    stdid: str
    stdpw: str
    stdmail: str
    countia: str
    celestia: str
class dataToSend(BaseModel):
    dataToSend: str
@app.post("/api/data")
async def receive_data(Directa: directa):
    print(Directa)
    return {"message": "Data received", "data": dataToSend}
 
    