It has been a while since I was here but I decided to continue the series after being busy for a long time.
I took a look at what the gekko ticker stores from an incoming candle, and I found there’s a Unix timestamp in there. That’s an integer. So, even though I probably will not use that integer as a parameter for the api it is very convenient for testing.
Let’s create an endpoint with an integer as input, outputting a string as result. It can’t get any simpler.
So I created a web page with a little JS in it, logging to the console first. Let’s see what I get…
Hmm.. CORS? There is a Cross Origin Resource Sharing error here.. So what is wrong? I think it is because (and I am skipping a few steps here) because my request comes from the https website and the api part is http. This is a security thing which is good because the web server protects you from having requests from a different site than yours. In this case it is because the requests are from different port numbers: https is port number 443 and http is port 80. So I need to fix this.
And of course, fetch expects a json result, not a string, so let’s fix this.
Next I will be diving more into the Gekko docs and see if I can make it call my API, maybe storing some logs of it anywhere, maybe in the database..