Ibm mobilefirst 从Worklight JSONStore调用push/pushSelected方法时如何读取服务器响应?

Ibm mobilefirst 从Worklight JSONStore调用push/pushSelected方法时如何读取服务器响应?,ibm-mobilefirst,jsonstore,Ibm Mobilefirst,Jsonstore,我试图找出在调用JSONStore push/pushSelected函数时如何获得服务器响应。 我知道我可以通过以下方式处理成功: .then(function (res) { //handle success //res is an empty array if all documents reached the server //res is an array of error responses if some documents failed to reach

我试图找出在调用JSONStore push/pushSelected函数时如何获得服务器响应。 我知道我可以通过以下方式处理成功:

.then(function (res) {
    //handle success
    //res is an empty array if all documents reached the server
    //res is an array of error responses if some documents failed to reach the server
})
但我真正想要的是读取服务器响应,它对我来说有重要的信息

我甚至尝试使用onSuccess回调(在代码下面),但它也不起作用

var options = {
    onSuccess: function(response){
        WL.Logger.debug("response: "+JSON.stringify(response));
    }
};
myCollection.pushSelected(doc, options)
.then(function (res){
     ...
});
它打印“响应:0”

我有办法做到吗


提前感谢。

您可以在accept函数中读取适配器的响应

accept:function(adapterResponse){return(adapterResponse.status ==200);}

文档页面中有一个示例


如果你想要别的东西,我建议你买一个。

它奏效了!谢谢我所做的是使用一个全局变量来保留我需要的响应值,并在调用“pushSelected”后引用它。