Search code examples
javascriptbixbybixbystudio

Does Bixby really support ES6? const / let keywords malfunction


When looping with an object, const, let keywords malfunction on Bixby capsule local-endpoint javascript.

I ran Bixby studio on my laptop(Ubuntu 18.04). Trying Bixby simulator, on debug console api result is constructed in an unexpected way.

var http = require('http')
var console = require('console')
var config = require('config')
module.exports.function = function getBTCRates () {
  console.log("GET /ticker without any parameter!)")
  // Read the remote.url value from capsule.properties
  var response = http.getUrl(config.get('blockchain.url') + '/ticker', { format: 'json' });

  var items = [];
  for (var currency in response) {
      var item = response[currency];
      item.quarterBefore = item['15m']
      delete item['15m'];
      item.currency = currency;
      items.push(item)
  }
  return items;
}

If I change var keywords to const or let as follows, it malfunctions.

var http = require('http')
var console = require('console')
var config = require('config')
module.exports.function = function getBTCRates () {
  console.log("GET /ticker without any parameter!)")
  // Read the remote.url value from capsule.properties
  var response = http.getUrl(config.get('blockchain.url') + '/ticker', { format: 'json' });

  const items = [];
  for (let currency in response) {
      const item = response[currency];
      item.quarterBefore = item['15m']
      delete item['15m'];
      item.currency = currency;
      items.push(item)
  }
  return items;
}

When I use const, let keywords, result is as follows:

wrong result

When I use var keywords, result is as follows:

right result


Solution

  • A few suggestions:

    1. Check if it's Ubuntu specific issue since Bixby IDE for Ubuntu is only in Alpha stage. You can test your code on a MAC or PC.
    2. The debug console in IDE offers better details about exceptions. It is possible that JS run into an exception but capsule still try to carry on with whatever default/previous value it can get.
    3. Change only const or let to isolate the issue.
    4. You can submit a diagnostic using IDE's contact support function under help menu.