I am calling postUrl in action-javascript that is referenced from Bixby sample on https://github.com/bixbydevelopers/capsule-samples-collection/tree/master/http-api-calls
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";
}
BTW, postUrl to my remote service runs only one time, all later postUrl does not come into my remote service. Then I need to restart Bixby developer studio again to get postUrl to my remote service.
With getUrl, there is no symptom above. Did I miss any constraint about using postUrl ?
Thanks in advance.
It looks like the Bixby platform caches the response from your remote server, and keeps re-serving it to your capsule code. I found that the solution is to set the cacheTime
in the options to 0, and this makes the Bixby platform call your remote server again every time. Substitute the following for your options above (adding cacheTime
on its own line):
var options = {
passAsJson: true,
returnHeaders: true,
format: 'json',
cacheTime: 0 // <--- this is the new line to add
};
I found this out when I wrote a tutorial capsule using remote storage. I was using http.postUrl
to access my remote server and had to update the options for the postUrl
call at this place in the code, or it wouldn't call the remote server more than once. The solution was setting the cacheTime
to 0, as I mentioned above.