Hola @david
Just a couple of technical questions about JavaScript libraries that Glide uses in their plugins: Fetch JSON & JavaScript.
I know we cannot make POST requests by using the Fetch JSON column but our plan B can be a custom JS code and run it via JavaScript plugin. It’s is fine but sometimes I have problems to understand and find the correct syntax within all the JS libraries and flavors available around the world.
I read time ago that Glide uses Lodash as JS library and also, we can import other JS libraries but I have a doubt about the Fetch() function and the right/best syntax to use.
As you know, Fetch() API supports the Promise object and helps a lot to retrieve/handle data and intercept any error during the execution of the request.
For example, this simple code uses Promise objects:
fetch('https://yesno.wtf/api')
.then(response => response.text())
.then(result => console.log(result))
and returns these values using text format (.text()):
`
{“answer”:“no”,“forced”:false,“image”:“https://yesno.wtf/assets/no/1-c7d128c95c1740ec76e120146c870f0b.gif”}
but the above code cannot be used in Glide, the JS plugin doesn’t support it and we must change it using this syntax:
var Response = await fetch('https://yesno.wtf/api')
const Result= await Response.text();
return Result
Glide shows the result like (all is ok)
…
As you can imagine, if I try to run my Glide code in other JS editors, nothing works
So, my questions are:
- Which JS library can I import into Glide in order to work/use Fetch API’s Promise objects?
- If I want to use Bearer authorization in Glide’s JavaScript plugin, which JS library do I have to import/use?
- If I want to test my Glide JS code on other online platforms like JSFiddle, what language do I have to choose to get right results?. I tested it using “TypeScript” but no luck!
Thanks David, saludos!