The front end invokes the page and the corresponding JS code

/ / this method for hospital set up the information query with paging hospitalSetApi. GetPageList (1, 10, null). Then (response = > {. This list = response. Data. Records})Copy the code
getPageList(page, limit, searchObj) { return request({ url: `${api_name}/findPageHospSet/${page}/${limit}`, method: 'post', data: {hosname: 'Beijing People's Hospital'}})}Copy the code

Baidu searched for a solution to the related error and found that it was. Then, but no catch processing was added. However, errors that affect data return do not occur if this processing is not previously added. Let’s just add it and see what it looks like

hospitalSetApi.getPageList(1, 10, null).then(
        response => {
          this.list = response.data.records
        }
      )
        .catch(err => {
          this.$message.error(err.message)
          console.log(err)
        })
Copy the code

At this time, no information is printed on the console, but an error pop-up box is displayed with a message indicating success. The project uses the VUE framework. This popup box is wrapped with vUE error message in utils/request.js

const res = response.data if (res.code ! == 200) { Message({ message: res.message, type: 'error', duration: 5 * 1000 })Copy the code

Message is what is displayed, which is the ‘success’ displayed on the front end. This message indicates that the status code returned by the backend is not equal to 200, but the message here is success, which means that the backend processing is fine.

At this point, the problem has been identified: the correct status codes at the front and back ends are inconsistent

Modify the status code

The data in the database is displayed normally.