租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
636 B

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. /**
  2. * 响应拦截
  3. * @param {Object} http
  4. */
  5. export const responseInterceptors = (vm) => {
  6. uni.$uv.http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/
  7. const data = response.data
  8. if (data.code !== 200) { // 服务端返回的状态码不等于200,则reject()
  9. uni.$uv.toast(data.message)
  10. return Promise.reject(data)
  11. }
  12. return Promise.resolve(data);
  13. }, (response) => { /* 对响应错误做点什么 (statusCode !== 200)*/
  14. console.info('interceptors.response---------',data)
  15. return Promise.reject(response)
  16. })
  17. }