[Vuejs]-Django Rest Framework Path working for one link, but not for other with same setup

0👍

From the response

GET http://127.0.0.1:8000/teacherssubjects/?teacherid=3 404 (Not Found)

it seems the string ?teacherid=3 is being passed instead of 3 as you expect

Try using backticks in the url string of the get request like this:


async getSubjectsforTeacher(teacher){
                await getAPI.get(`/teacherssubjects/${teacher}/`)            
                    .then(response =>{
                        this.SubjectsforTeacherData[teacher] = response.data
                        console.log(this.SubjectsforTeacherData)
                    }).catch(error =>{
                        if (error.response){
                            console.log( error.response )
                        }else if(error.request){
                            console.log( error.request )
                        }else if(error.message){
                            console.log( error.message )
                        }
                    })
               }

Leave a comment