I have an API which gets records from Mongodb. When I call records from db, records are coming, there is no problem. But it’s not working on the host. There is an error on console like Failed to load resource: the server responded with a status of 404 () api/improve-language?cat=general:1
.
My codes where I’m trying to get datas:
useEffect(() => {
getAllData(category)
}, [])
async function getAllData(cat){
if(cat){
cat = `?cat=${cat}`
} else{
cat = ``
}
axios
.get(`/api/improve-language${cat}`)
.then(res => {
setAllWords(res.data)
setNeverAskedWords(res.data)
newQuestionAndAnswers(res.data)
})
.catch(err =>{
console.log(err)
})
}