我正在打这个电话:
axios.get('/groups', {
baseURL: 'http://localhost:5000',
headers: { Authorization: 'Bearer ' + getAccessToken(), 'Content-Type': 'application/json; charset=utf-8' }
})
.then((response) => {
console.log('then response',response)
success(response.data)} )
.catch((response) => {
console.log('catch response',response)
error(response.status, response.data.description)})
我只调用一次。我收到 200 OK 响应,then
块执行,并且response
是我通常期望的对象。执行之后catch
,响应是一个字符串:
TypeError: Cannot read property 'groups' of null(…)
结束语:我的错,这是代码中很远的地方出现的错误,仍在尝试弄清楚它是如何实现承诺的......