Hello I’m a very basic developer, but would want to try to display all my gumroad items on a separate ghost page.
So what I found is this:
Now the problem I’m facing is that the access token is in the data argument, meaning if I’m using Jquery people can see this token, it should remain a secret according to Gumroad.
What are my options to do the following and which programming language should I use that is compatible with Ghost?
- GET from the gumroad API to get the products in a json as a response
- This without exposing the access token
- Convert the json into html
After thinking a bit, I just made another container with nodejs which does the request to gumroad for the products. I then save the products to a json file.
All I need to do now is read that file using jquery in Ghost and convert it to html which is the easiest part.
If there’s a better way, please let me know.
That seems like an OK approach.
Seems fine. Are you triggering the request to gumroad based on time, or when the user requests? If on user requests, then I’d have the node server just pass back the data to the client, rather than writing a file and having the client read it, which could get tricky.
Another option if you want to improve page load times and possibly SEO would be for the nodejs to notice new products (via a gumroad webhook if those exist, or by occasionally scanning) and use the adminAPI to create a new post for each one within the Ghost site.
It could get tricky indeed. That’s why I’m getting the products and writing them to a JSON file every 5 minutes.
Your second approach is much better than mine, but kind of surpasses my knowledge at the moment to do so. Thank you though!
I had to create my own API, because of the following reason.
The gumroad products json file gets read fine, but is loaded into the cache.
So when a change is made in that file, it won’t update on my website without reloading the page without the cache (ctrl + f5).
This is a huge problem as users won’t use ctrl+f5.
So I created my own api without a necessary authentication that only shows the products in there.
Just leaving this here if someone else tries to do it.