0

I'm incredibly new to HTML/Javascript/API's and im trying to make my first chrome extension using coinmarketcaps' public API.

API: https://api.coinmarketcap.com/v2/ticker/?limit=12&sort=rank&convert=ETH

My Code:

console.log("Running");
function setup() {
    loadJSON('https://api.coinmarketcap.com/v2/ticker/? 
    limit=12&sort=rank&convert=ETH', gotData, 'jsonp');
}
setup();

function gotData(data){
    console.log(data);
    list = data;
}

gotData();

Essentially what I want to do is load in the data and then print the data to my console to make sure that it is in fact loaded. The error that I'm getting when i check the background.js console after uploading the extension is 'loadJSON is not defined'

I don't know if im missing a package or am unable to use such a command but after looking online for a while I can't seem to figure it out. Another thought that I had was maybe it can't be used in a background.js file. Also, I am using Atom software for this project. Let me know if you need any more information, any help is appreciated.

Colin
  • 13
  • 4
  • You need to learn to make api calls/requests. According to your question above, you need to make a GET type request. Please refer to the following links. https://medium.com/@charlottebrf/making-api-requests-in-javascript-web-apps-c1d025470ddb https://stackoverflow.com/questions/247483/http-get-request-in-javascript – Jehanzeb.Malik Jul 30 '18 at 21:56
  • Where does `loadJSON` come from? Is it defined as a function somewhere in your code? Do you `require`/`import` it or do you load it in your HTML? – idleberg Jul 31 '18 at 08:49

0 Answers0