HTTP request in babylon environment

I want to get data from an API. I want to show for example the temperature in a textblock. I can get my data with an http request like this:

curl --location -g --request GET ‘URL/read?filter[limit]=1’ \

–header ‘Authorization: specfic secret code’ \

–header ‘Content-Type: application/json’

How can I convert this to the main.js where I coded with BabylonJS?

1 Like

Babylon has no control over the way you are interacting with your server.

I would recommend you to explore the fetch api - Fetch API - Web APIs | MDN

If authorization is required for requests made inside babylon you can add your headers to BABYLON.Tools.CustomRequestHeaders (a string:string map) and set BABYLON.Tools.UseCustomRequestHeaders to true

1 Like