这个问题在这里已有答案:
我正在尝试检查来自api调用的结果是否返回任何内容并基于其他一些操作,但是下面的代码总是通过process_result()函数,即使结果是一个空对象,任何人都可以看到我的'我做错了,
RemoteApi.api_request(server, method, url, data)
.then(result => {
debug("result from API request: ", result)
debug("data from API request: ", data)
if (result !== {}) {
debug("in process result now")
process_result(result, label, model, dispatchOptions)
.then(body => {
onSuccess(body)
})
.catch(error => {
onFailure(error)
})
} else {
debug("outside process result now")
}
})
.catch(error => onFailure(error))