I have to make http api calls to another server that doesnt use websockets. I was thinking of using long polling for it to get the data but havent seen any documentation about it? right now, im using ajax to make the request. just wondering if there is a better way to do it in phoenix.
Ajax is the client side.
Do you need to make the call from phoenix server? If so I would use an available http client like httpoison.
I make the call from phoenix but I wanted it to do long polling to check the server every x amount of time so was using ajax on the js file inside of phoenix but then got stuck because of cors stuff even after installing the cors plugin. can i do long polling with httppoison?
You can use a timer, or Process.send_after.
If it was me, I would span a genserver, that will fire an event each x amount of time.
thanks! will try to create a genserver with httppoison + timer/Process.send_after.
still have a lot to learn.
Have a look at this post Scheduled function - Task or Agent?
There is some sample code, plus some good comments related (Not the httpoison part)
thanks will check it out need me some more elixir