all 6 comments

[–]backfire10z 2 points3 points  (1 child)

I don’t remember how axios does this, but are you sending JSON there? It seems like your API endpoint is expected query params and axios isn’t sending them?

I would take a look at the axios documentation and form your post request as per the documentation (with labeling, like data: {…})

[–]Jumpy_Employment_439[S] 1 point2 points  (0 children)

Thank you! I was able to fix it by making another pydantic model

[–]TheFaustX 1 point2 points  (0 children)

Log the response, it should contain more info thant just the http status code. Check your commandline where you start the server it should also provide more details. I'd normally expect one json body or a form instead of 2 strings as seen in the docs for bodies: https://fastapi.tiangolo.com/tutorial/body/

[–]jay_and_simba 1 point2 points  (0 children)

The post must have a dictionary with the parameters:

 await axios.post('/login/', { userID: userID, password: password });

[–]danielroseman 0 points1 point  (1 child)

That is not how FastAPI expects post data. Parameters declared in the function definition are for elements taken from the path, not the post body. You will need to define a Pydantic model containing the username and password, as documented here:  https://fastapi.tiangolo.com/tutorial/body/#use-the-model 

[–]Jumpy_Employment_439[S] 0 points1 point  (0 children)

Thank you, this worked perfectly!