Is there any sample or example code of using network.request in HTML5 build

In the HTML5 Announcement, there is one section mentioned that:

“If your app makes calls to web servers, using API’s like network.request(), because of JavaScript cross-domain scripting rules, you can’t directly call REST type APIs. Instead you will need to write a local web script on the same domain that will make your REST API calls and then echo the returned data back to network.request().”

So, is there any sample or example code of using network.request in HTML5 build in this way above ? Such “write a local web script” and then how to integrate the local web script with network.request?

Hi,

I’m not sure this is entirely true depending on the API you are using, especially in regards to service based APIs. I am able to query against AWS fine locally. It depends on the back end service and how they handle authentication, which is generally through the use of headers.

Are you wanting to call a service based API or are you making your own?

-dev

Hello,

I need to “call a service based API”, it means a 3rd. party’s REST API.

No authentication is needed, just some public data to query, through REST API.

You can always try to call a service and see if it works. You’re mileage may vary.

Rob

Hi,

You can give it a test with network.request like @Rob Miracle suggested. If that doesn’t work try putting the html build up in an S3 bucket as a static site.

EDIT: Or your own host if you have one.

-dev

Thanks.

And update from myself:

Yeah, it works actually. I try the html5 build and it can call the remote 3rd party API through network.request.

My HTML5 build is here:

https://bobdos.github.io/sbd.ninja-website/web/index.html

It’s a tiny query tool for STEEM blockchain, and it’s still in developing from scratch, just V0.0.3 version.

Hi,

I’m not sure this is entirely true depending on the API you are using, especially in regards to service based APIs. I am able to query against AWS fine locally. It depends on the back end service and how they handle authentication, which is generally through the use of headers.

Are you wanting to call a service based API or are you making your own?

-dev

Hello,

I need to “call a service based API”, it means a 3rd. party’s REST API.

No authentication is needed, just some public data to query, through REST API.

You can always try to call a service and see if it works. You’re mileage may vary.

Rob

Hi,

You can give it a test with network.request like @Rob Miracle suggested. If that doesn’t work try putting the html build up in an S3 bucket as a static site.

EDIT: Or your own host if you have one.

-dev

Thanks.

And update from myself:

Yeah, it works actually. I try the html5 build and it can call the remote 3rd party API through network.request.

My HTML5 build is here:

https://bobdos.github.io/sbd.ninja-website/web/index.html

It’s a tiny query tool for STEEM blockchain, and it’s still in developing from scratch, just V0.0.3 version.