Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request2.js:36 Uncaught Error: 登录失败 #3

Open
snowdream opened this issue Oct 29, 2019 · 0 comments
Open

request2.js:36 Uncaught Error: 登录失败 #3

snowdream opened this issue Oct 29, 2019 · 0 comments

Comments

@snowdream
Copy link

When i want to throw erros in the function, it shows "Uncaught Error"

const intercept = require('superagent-intercept')((err, res) => {
  if (err) {
    throw new Error(err)
  }

  if (res) {
    /**
     * code为非0是抛错 可结合自己业务进行修改
     */
    const data = res.body
    if (data.code !== 0) {
      throw new Error(data.message)
    }
  }
})
request2.js:36 Uncaught Error: 登录失败
    at Request.<anonymous> (request2.js:36)
    at index.js:8
    at Array.forEach (<anonymous>)
    at Request.req.callback (index.js:8)
    at Request.<anonymous> (client.js:465)
    at Request.Emitter.emit (index.js:145)
    at XMLHttpRequest.xhr.onreadystatechange (client.js:761)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant