Discuss Scratch

EDO2012
Scratcher
100+ posts

Calling an API with an extension

I was trying to make an extension that calls the Dogechain API.
I tried to use the weather extension as an example
/* Extension demonstrating a blocking reporter block */
/* Sayamindu Dasgupta <sayamindu@media.mit.edu>, May 2014 */


new (function() {
var ext = this;

// Cleanup function when the extension is unloaded
ext._shutdown = function() {};

// Status reporting code
// Use this to report missing hardware, plugin or unsupported browser
ext._getStatus = function() {
return {status: 2, msg: 'Ready'};
};

ext.getBal = function(location, callback) {
// Make an AJAX call to the Open Weather Maps API
$.ajax({
url: 'https://dogechain.info/api/v1/address/balance/'+location,
dataType: 'jsonp',
success: function( weather_data ) {
// Got the data - parse it and return the temperature
temperature = weather_data['balance'];
callback(temperature);
}
});
};

// Block and block menu descriptions
var descriptor = {
blocks: [
['R', 'dogecoin balance for %s', 'getBal', 'Boston, MA'],
]
};

// Register the extension
ScratchExtensions.register('Weather extension', descriptor, ext);
})();
but I would get this error
11:01:11 AM | err | Error: Error #1023

Don't know if this would be useful: My browser / operating system: Windows NT 10.0, Chrome 54.0.2840.99, Flash 23.0 (release 0)


Powered by DjangoBB

Standard | Mobile