0

screenshot

How can Replace ' with an Apostrophe ' in Bixby? I am new to Bixby studio. So please help.

var http = require('http');
var console = require('console');
var config = require('config');
var base64 = require('base64');

module.exports.function = function FindRecipes(type) {
    console.log("FindRecipe filter by a specific type");
    var options = {
        format: 'json', query: { search: type }
    };

    var response = http.getUrl(config.get('remote.url'), options);

    return response;
}
Álvaro González
  • 142,137
  • 41
  • 261
  • 360

1 Answers1

0

The file for your Bixby project is Javascript.

So you can use the .replace() function (I am assume response is a String).

Use the g flag in the regex to replace more than one instance of the string.

return response.replace(/'/g, "'");

Edit:

To fix the encoding on all properties since response is an object.

for (var prop in response) {
  response[prop] = response[prop].replace(/'/g, "'");
}
Jonathan Rosa
  • 992
  • 7
  • 22
  • {"id":"","source":"","qsource":"","duration":"","servings":"","calories":"","favcount":"","ingredients":"","directions":""} this is my response (json) – Nithin P Molethu Apr 12 '20 at 17:07
  • @NithinPMolethu Is the `response` an object or a string? I know it's json, but is it already parsed? I had edited my answer, try it – Jonathan Rosa Apr 12 '20 at 17:17