Problem:
I am trying to setup my server to receive get and post requests with express. I have different client javascript code that I want to send requests to the server.
Client Code:
const response = await fetch('/RetrieveCustomerInformation');
Server Code:
application.get('/RetrieveCustomerInformation', (request, response) => {
console.log("Got here!")
console.log(request, response)
customerRecordsdb.find({}, (error, data) => {
if (error) {
response.end();
return;
}
response.json(data);
})
})
File Hierachy: : https://i.stack.imgur.com/kkS7o.png
Error Message: Failed to load resource: the server responded with a status of 404 (Not Found)
I have tried playing around with the relative paths, so both URLs in the first .get() parameter point to the same location, but no luck with that. Any help or advice would be greatly appreciated!
All the best.
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment