@Mohamed Hussein Thanks for reaching out to Microsoft Q&A.
Calling Rest API endpoint(http/https) from java script inline code action is not supported.
Refer to this documentation to know more information about the list of methods that are supported by Java script standard built-in objects.
Better way would be making the call using http action and the output of this action pass to inline code and also inline code supports regex expression.
Hope this helps, let me know if you have any further questions on this.
Please accept as Yes if the answer is helpful so that it can help others in the community.