我写了Action,应该从db.json文件中获取数据.但
错误:消息"xhr.js:178 GET http:// localhost:8083/data/db.json 404(Not Found)".
为什么,如果我的路径是正确的(db.json在同一个文件夹中)?在profileActions.js中:
import axios from "axios";
var customData = require('./db.json');
export function fetchUsers(){
return function(dispatch){
axios.get('./db.json')
.then((response) => {
dispatch({type:'FETCH_USERS_FULFILLED', payload:response.data});
})
.catch((err) => {
dispatch({type:'FETCH_USERS_REJECTED', payload:err});
})
}
}
Run Code Online (Sandbox Code Playgroud)