我是新的反应终极版,以及所有我已经做了:
1)激活我的后端服务器(本地主机:5000)
2)采用NPM启动激活我前端服务器(本地主机:8080)
3)我试图通过使用派遣行动
this.props.dispatch({type: ActionTypes.FILE_UPLOAD_REQUEST, email: this.state.email, file: this.state.policyFile});
4)使用阿特拉斯 - 传奇,并调用与调度相关的我的服务功能:
let result = yield call(Atlas.uploadFile, action.email, action.file);
5)定义该函数为:
export const uploadFile = (email, file) => { return fetch(`${BASE_URL}/v1/files/${email}/policies`, { method: 'POST', headers:{} , body: {'file': file} }) .then(response => response.json()) }
之后,我试着在我的反应(即调用调度函数)来运行的功能,它给了我,他们不能发现的行车路线错误。 这是从控制台的错误消息。
Fetch API cannot load https://api-staging.autoarmour.co/v1/files/fakeemail@gmail.com/policies. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 500. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
是的,我没有创建任何减速,只是单纯的功能,将上传文件。 谢谢