我使用redux thunkMiddle来实现异步操作,但在actions中发送Http请求时出错,错误为:
VM711:3 Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.
at Object.performAction (<anonymous>:3:2312)
at liftAction (<anonymous>:2:27846)
at dispatch (<anonymous>:2:31884)
我需要向我的API端点请求上传一个文件。我在我的项目中使用了axios,但是与它一起附加一个文件似乎是个问题,而使用Superagent应该是简单明了的。但是,我的Saga代码不适用于Superagent(没有响应对象,API没有触发),我做错了什么?
import { delay } from 'redux-saga';
import { select, call, put } from 'redux-saga/effects';
import request from 'superagent'
import * as action fro
这是一个superagent调用,我已经导入了请求(即从我的superagent组件类导出),如何在此调用中对"res.resImpVariable“使用async/await。
request
.post(my api call)
.send(params) // an object of parameters that is to be sent to api
.end((err, res) => {
if(!err) {
let impVariable = res.resImpVariable;
} else {
console.lo
问题:
我试着用超级探员重试我最初的请求。下面是一些伪的:
function postRequest({
parameters
}) {
return superagent.post(url)
.set("Authorization", `Bearer ${process.env.initialToken}`)
.send({data})
.then(res => {
if (res.unauthorized) {
// I want to make a API call, get a new