代理错误:无法将请求/ api / games从本地主机:3000代理到http://localhost:8080/(ECONNREFUSED)。
action.js(Redux)中的代码
export function fetchGames(){
return dispatch =>{
fetch('/api/games')
}
}
import express from 'express';
import mongodb from 'mongodb';
const app = express();
const dbUrl = 'mongodb://onkar localhost:27017/crudwithredux';
mongodb.MongoClient.connect(dbUrl, function(err, db) {
app.get('/api/games', (req, res) => {
db.collection('games').find({}).toArray((err, games) => {
res.json({ games });
});
});
app.listen(8080, () => console.log('Server is running on localhost:8080'));
});
**嗨,我是onkar,我是React JS的新手。我在服务器页面中收到错误。我有mongo db数据库,所以我从mongo db检索了数据。并使用redux在js中以Json格式显示。**