Author Topic: Javascript http request  (Read 10021 times)

rukavinamilan

  • Newbie
  • *
  • Posts: 3
    • View Profile
Javascript http request
« on: March 16, 2018, 01:35:43 PM »
I was reading docs but I cannot find a way to make http request from javascript (fetch api)? Or at least call from javascript shell (curl) to do so?

Thanks

Monica Tepelus

  • Administrator
  • Full Member
  • *****
  • Posts: 198
    • View Profile
Re: Javascript http request
« Reply #1 on: March 20, 2018, 06:34:36 AM »
Hi,

You can't do the actual call from javascript because javascript is embedded in Yate, and yate doesn't have http support. What you can do is have an external php script, with a handler for a custom message. Ex: http.request. Send the message from javascript and let the php scrit do the call.

rukavinamilan

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Javascript http request
« Reply #2 on: March 29, 2018, 11:22:32 AM »
Thanks Monica!
I'm aware of that option, but that's seems suboptimal, since javascript seems to work fast since it does not depend on external module...being able to make http request or shell exec would make it very flexible.

Thanks!

asymetrixs

  • Administrator
  • Newbie
  • *****
  • Posts: 47
    • View Profile
Re: Javascript http request
« Reply #3 on: April 03, 2018, 01:25:48 PM »
The javascript interpreter is custom build, so it lacks lots of functionality that e.g. V8 would offer, because it was specifically for use with yate.

dorinelromeo

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Javascript http request
« Reply #4 on: December 02, 2021, 08:43:11 AM »
Hello,

I'm having the same issue, I want to make a GET request with A number to get B number from external API. I've tried implementing the HTTP client from here: https://docs.yate.ro/wiki/HTTP_Client but with no success.
Maybe I'm missing something here.

What should new Message("http.request",false,params); do? Do I need to create a php file to handle the GET request?

Thank you!

Monica Tepelus

  • Administrator
  • Full Member
  • *****
  • Posts: 198
    • View Profile
Re: Javascript http request
« Reply #5 on: December 02, 2021, 08:55:43 AM »
Hi,

httpclient module is only available in the private yate version.

Before implementing this we used below script and that is in a public repo.

http://yate.null.ro/websvn/filedetails.php?repname=yate-common&path=%2Ftrunk%2Fscripts%2Fhttp_req.sh

Monica