Friday, December 25, 2020

Can't get data from api, http_get

Hey,

I've recently picked up Gamemaker for the first time in a while, and I'm trying to get data from an api. Coingecko to be exact. https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=eur&include_market_cap=false&include_24hr_vol=false&include_24hr_change=false&include_last_updated_at=false

I'm trying to get the value from the "eur:", but for some reason it doesn't work. I've followed a tutorial on Youtube, and when I'm using their resources with the same code, it works. But not when I'm trying to use Coingecko.

My code in the HTTP event: json = async_load[? "result"];

map = json_decode(json);

if (map == -1) {

show_message("Error.");

exit;

}

if (ds_map_exists(map, "eur")) {

price = map[? "eur"]

show_message("The title is: " + price)

}

But nothing happends.

Does anybody know why and can help me? Thanks in advance.


No comments:

Post a Comment