Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

how to change promise resolve value in the response #595

Open
LiDengHui opened this issue Apr 19, 2017 · 0 comments
Open

how to change promise resolve value in the response #595

LiDengHui opened this issue Apr 19, 2017 · 0 comments

Comments

@LiDengHui
Copy link

I need change promise resove value

Vue.http.interceptors.push(function (request, next) {
  // ...
  // 请求发送前的处理逻辑
  // ...
  next(function (response) {
    // ...
    // 请求发送后的处理逻辑
    // ...
    // 根据请求的状态,response参数会返回给successCallback或errorCallback
    let res = response.body
    if (typeof res === 'object' && res.code) {
      if (res.code === 200) {
        return response
      } else if (res.code === 4101) {
        // response.ok = false
      } else if (res.code === 5001) {
        // response.ok = false
      } else {
        // response.ok = false
      }
      return request.respondWith(response.body, {
        status: res.code,
        statusText: res.message || '服务器错误'
      })()

response.body.code ===4101 need reject some value.
thank you

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant