Having trouble getting http-functions output via PHP file_get_contents

It works fine as a straight URL, but trying to get the results through code, using a PHP file_get_contents OR curl, it is hit and miss. MOST times it returns nothing, but if I keep refreshing eventually I get a result! What’s with that?? This is the example that is standard when you first create http-functions.js (although mine had a syntax error that took a while to uncover - since I assumed a canned example would already work!)

mysitedomain /_functions-dev/example/multiply?leftOperand=3&rightOperand=4

Output is simply

{"product":12}

but why can’t I consistently get that through PHP rather than typing the URL directly?

By the way, my goal is to return order information for outside fulfillment, but the http-functions example is the simplest way to show this problem. and it’s not my PHP code, cause it DOES return the proper results - sometimes. This is very frustrating!

Are you sure you “wait” for the Promise to be fulfilled on the PHP-side? Because if you say “sometimes”, it might be just that.

How do you make it wait?

Now I’m getting ‘502 Bad Gateway’ using PHP/Curl on the same exact URL that works fine directly in the browser