reactjs 发布http://localhost:5000/task/mat 400(错误请求)

xxls0lw8  于 2023-02-04  发布在  React
关注(0)|答案(1)|浏览(181)

我在控制台中遇到此错误:

react_devtools_backend.js:4012 A non-serializable value was detected in an action, in the path: `meta.arg.config.adapter`. Value: ƒ xhrAdapter(config) {
  return new Promise(function dispatchXhrRequest(resolve, reject) {
    var requestData = config.data;
    var requestHeaders = config.headers;
    var responseType = config.resp… 
Take a look at the logic that dispatched this action:  
{type: '[GET] dataGrid/runTask/rejected', payload: undefined, meta: {…}, error: {…}}
error
: 
{name: 'Error', message: 'Request failed with status code 400', stack: 'Error: Request failed with status code 400\n    at …tp://localhost:3000/static/js/bundle.js:208909:7)'}
meta
: 
{arg: {…}, requestId: 'XNHo_e78g2enuXNwLe_pQ', rejectedWithValue: false, requestStatus: 'rejected', aborted: false, …}
payload
: 
undefined
type
: 
"[GET] dataGrid/runTask/rejected"
[[Prototype]]
: 
Object

谁能告诉我问题出在哪里,因为后端工作得很好。
所述代码部分为:

const requestConfig = {
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
    };

    export const getReportsList = createAsyncThunk(
        '\[GET\], dataGrid/reportsList',
        async (\_) = \ > {
            const response = await getData(ENDPOINTS.all_reports)
            return response.data
        }
    )
nx7onnlm

nx7onnlm1#

Modify Your Code

const requestConfig = {
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
  },
};

export const getReportsList = createAsyncThunk(
  "[GET], dataGrid/reportsList",
  async (_, { getData, ENDPOINTS }) => {
    const response = await getData(ENDPOINTS.all_reports, requestConfig);
    return response.data;
  }
);

Note : The getData function and ENDPOINTS object need to be imported and provided to the createAsyncThunk middleware as dependencies in order to use them within the thunk

相关问题