Reputation: 1
I am new to reactJs i need to fetch value from DB using an axios call, But it's showing 404 error Here is my code
axios({
method: 'POST',
contentType: 'application/json; charset=utf-8',
url:'http://localhost/projectName/backend/web/category-master/fetch-category',
responseType: 'json'
})
Upvotes: 0
Views: 42
Reputation: 823
Try the following, First check your url route method if it accepting post method.
axios.post(url,data, {
headers: {
'authorization': your_token_if_any,
'Accept' : 'application/json',
'Content-Type': 'application/json'
}
})
.then(response => {
// return response;
})
.catch((error) => {
//return error;
});
Upvotes: 0
Reputation: 5452
Problem is missing port number after localhost. Please set port number and try again
axios({
method: 'POST',
contentType: 'application/json; charset=utf-8',
url:'http://localhost:[PORT]/wellnesscc/backend/web/category-master/fetch-category',
responseType: 'json'
})
For example:
If your backend applciation's port is 5000, correct version as below:
axios({
method: 'POST',
contentType: 'application/json; charset=utf-8',
url:'http://localhost:5000/wellnesscc/backend/web/category-master/fetch-category',
responseType: 'json'
})
Upvotes: 1