Calling external web service using Amazon sumerian

301 Views Asked by At

I am new to Amazon Sumerian and been exploring it's features however I am still not sure about one thing.

  1. How do I call external web service using Amazon sumerian scripting or Sumerian interface?

I am a front end resource and diving into 3d world for some time now. Could you please assist me to any documentation or example for my query. I do not have any code to support my query as of now, I just need some pointers to further my research.

Thank you

2

There are 2 best solutions below

0
On

Add a script in Entity you want to call external web service. Inside script call web service.

var xhr = new XMLHttpRequest();
xhr.open("GET", "https://newsapi.org/v2/top-headlines");
xhr.send(null);

xhr.onload  = function() {
    var jsonResponse = JSON.parse(xhr.responseText);
    console.log('Response => ', jsonResponse);
};

Make sure you add this inside proper function.

For example I added it inside function setup(args, ctx) {} of the script.

0
On

Amazon Sumerian runs in your web browser. You can trigger JavaScript within Sumerian.

So, just take JavaScript code that can call your external web service and put it into the script.

See: Scripting - Amazon Sumerian