React + Express: Proxy Error: Could Not Proxy Request /total From Localhstem_errors
This is a follow-up question from my previous question React.js: Axois Post stay on pending(but i am getting data) My package.json file { 'name': 'my-app', 'version': '0.1.0',
Solution 1:
Can you try setting your proxy in package.json like
"proxy":{"/*":{"target":"http://localhost:3001"}}
Regarding below error the res.sendStatus
should be placed out of mongo connection
Can't set headers after they are sent
MongoClient.connect(url, { useNewUrlParser: true }, function(err, db) {
if (err) throw err;
var dbo = db.db("cart");
var objs = req.body;
dbo.collection("items").insertMany(objs, function(err, result) {
if (err) console.log(err);
console.log("Number of documents inserted: " + result.insertedCount);
db.close()
});
});
res.sendStatus(200)
});
Post a Comment for "React + Express: Proxy Error: Could Not Proxy Request /total From Localhstem_errors"