我正在从https://github.com/bixbydevelopers/capsule-samples-collection/tree/master/http-api-calls的 Bixby示例引用的action-javascript中调用postUrl
var http = require('http')
var console = require('console')
var config = require('config')
module.exports.function = function adjustVolume (volume) {
var o = { };
var options = {
passAsJson: true,
returnHeaders: true,
format: 'json'
};
var response = http.postUrl(config.get('remote.url') + '/api/gvm/control/volume/' + volume, o, options);
return "ok";
}
Run Code Online (Sandbox Code Playgroud)
顺便说一句,到我的远程服务的postUrl仅运行一次,以后所有的postUrl都不会进入我的远程服务。然后,我需要再次重新启动Bixby Developer Studio,以将postUrl转到我的远程服务。
使用getUrl,上面没有任何症状。我是否错过了使用postUrl的任何限制?
提前致谢。
看来Bixby平台缓存了来自远程服务器的响应,并一直将其保留给您的压缩代码。我发现解决方案是cacheTime将选项中的设置为0,这使Bixby平台每次都再次调用您的远程服务器。将以下内容替换为上面的选项(单独添加cacheTime):
var options = {
passAsJson: true,
returnHeaders: true,
format: 'json',
cacheTime: 0 // <--- this is the new line to add
};
Run Code Online (Sandbox Code Playgroud)
当我使用远程存储编写教程胶囊时,我发现了这一点。我曾经http.postUrl用来访问我的远程服务器,并且不得不在代码postUrl中的此位置更新该呼叫的选项,否则它不会多次调用该远程服务器。如上所述,解决方案将设置cacheTime为0。