Search code examples
apipostaxiosroot

VueJS POST http://127.0.0.1:8000/login 404 (Not Found)


so i post this qs yesterday enter link description here
i was getting this **Uncaught (in promise) Error: Request failed with status code 405 VUEJS ** now i did fix the part of axios from this :

   axios.post('http://127.0.0.1:8000/?#/login/',{
            email: this.email, password: this.password
        }, headers)
        .then((response)=>{
            const data=response.data;
            console.log(data);
        })

to this

axios({
                method: "post",
                url: "/api/login/",
                data: {
                    email: "",
                    password: ""
                }
            }).then(
                response => {
                    console.log(response);
                },
                error => {
                    console.log(error);
                }
            );

now i'm getting this error
as u can see the problem and the api.php and the root


Solution

  • 405 error code means your api endpoint not allow the current method you requesting to so 405 errorbis aboutbendpoint problems, and about 404 response status in axios if server's response have a 4XX status it'll go directlly on catch it should be somthing like this:

    axios.post("http://127.0.0.1:8000/api/login/",{data: value,data1: value1})
    .then((res)=>console.log(res))
    .catch((err)=>{
         // 404 will be loged below
         console.log(err.response.status)
        console.log(err.response)
     }
    

    i have never saw somting like this but i think you should ckeck your api server and make sure you entered the currect url and currect port and make sure in your server logic response part you have'nt a type error or somithing im really sorry if it was'nt helpful

    p.s. i wrote the code above with my phone im really sorry its may be a little ugly

    and if you have some problems with your api server and your not a backend i can fix it(if its django) or i can make a simple one for you to use