0

getting content from readAsText()

Hi, 

I've been stuck trying to get the contents of a json file through params and readAsText().

I have the following:

function shapeGeneratorDefaults(callback) {
  var params = [
    {
      'id': 'markers',
      'displayName': 'Markers',
      'type': 'file',
      'accept': '.json'
    }
  ];
  callback(params);
}

function shapeGeneratorEvaluate(params, callback) { 
  var file = params['markers'];

  if (file) {
    file.readAsText(function(text) {
      Plugin.warning('readAsText');
      Plugin.warning(typeof text); 
    });
  }
}

It seems like whatever's in the callback in readAsText never gets invoked ...

Now, if I do

var data = file.toJSON();

I can see that there's a data.url which has the instance of the .json file I uploaded and following the url indeed leads to the json with appropriate content.

How can I get the content of the json? Any help would be appreciated!

Thanks!

Jimmy

 

 

2 comments

Please sign in to leave a comment.