React JS-未捕获(承诺)错误:请求失败,状态码为500

时间:2020-11-10 07:02:08

标签: javascript java reactjs

这是我的js的一部分

  initiallize = () => {
    console.log("error.response")
    this.updateUserData();
    this.updateGraphData();
  };

  async updateUserData(){
    const getResponse = invoiceManagementApiInstance.getRetailFinanceWorkspace();
    getResponse.then(response => {
      const responseData = response.data.data;
      console.log("from store allData=>",responseData);
      this.setDashboardData(responseData);
    })
    .catch(error => {
      console.log(error.response)
    });
  }
  
   async updateGraphData(){
        const getResponse = await invoiceManagementApiInstance.getRetailGraphData();
        console.log("getResponse---",getResponse);
        getResponse.then(response => {
            const responseData = response;
            console.log("from store graph Data=>",responseData);
            this.retailGraphData(responseData);
          })
          .catch(error => {
              console.log(error.response)
            });
      }

功能看起来像

  getRetailFinanceWorkspace = () => {
        return this.get(Urls.RETAIL_FINANCE_WOKSPACE);
      }
  
  getRetailGraphData = () => {
        return this.get(Urls.RETAIL_GRAPH_DATA);
      }

我有2个电话。对于updateUserData,我成功获得了对象,但是对于updateGraphData,我却得到了错误

GET http://localhost:xxxx/**********/retailGraphData 500 (Internal Server Error)
Uncaught (in promise) Error: Request failed with status code 500
    at createError (createError.js:16)
    at settle (settle.js:18)
    at XMLHttpRequest.handleLoad (xhr.js:59)

尽管我在后端看不到任何错误。我调试了代码,然后看到调试器到达了Java控制器,并完成了所有必要的操作,并成功返回了对象,但是仍然看到上面的错误。我的控制器看起来像:

   @RequestMapping(value = "/retailGraphData", method = { RequestMethod.GET })
    @ResponseBody
    public ServiceData retailGraphDataLoader() {
               // do all the stuff
          return serviceData1;
      }

任何指针吗?

0 个答案:

没有答案