I am using Node Js as backend and basic html css js for frontend. I am sending request through node js that
app.get("/send", async (req, res) => {
let products = await Product.find();
products = await products;
res.send(products);
});
and getting fetch on an html page:
const getData = async () => {
const response = await fetch("localhost:3000/send", {
method: "GET",
});
const data = await response.json();
console.log(data);
};
getData();
But i am not getting the data, I have tested the api on Postman it works fine there. But throwing error on browser:
Error is :
Fetch API cannot load localhost:3000/send. URL scheme "localhost" is not supported.
Please help me out. Bundles of thanks!
http://orhttps://