来自服务器的响应返回空结果,尽管之前在该 contextID 中成功保存了数据。大多数时候它返回 json 数据,但有时它返回空字符串,导致createNewGameAsync()函数,而不是直接进入populateFromBackend()函数。我正在从有关故障的https://glitch.com/edit/#!/panoramic-tendency项目创建后端。
loadData: function () {
var contextID = FBInstant.context.getID();
console.log('loadData from ' + contextID);
FBInstant.player.getSignedPlayerInfoAsync(contextID)
.then(function (signedPlayerInfo) {
var url = 'https://panoramic-tendency.glitch.me' + '/get-match'
var sig = signedPlayerInfo.getSignature();
var method = 'POST'
var payload = { 'signature': sig };
return req(url, method, payload);
})
.then(function (result) {
if (result.empty) {
return this.createNewGameAsync();
} else {
return Promise.resolve(result.data);
}
}.bind(this)).then(function (backendData){
this.populateFromBackend(backendData);
}.bind(this))
.catch(function (error) {
this.displayError(error);
}.bind(this));