Generally you are not supposed to call external APIs from within hyperledger as doing so can lead to conflicts between the peer nodes. Assuming every peer needs to perform the request the number of requests exponential increase with the number of nodes involved in your system.
There is how the documentation says external requests should be performed.That being said the documentation on external requests has not been updated for current hyperledger version as far as I can tell. https://hyperledger.github.io/composer/v0.19/integrating/call-out
Consensus considerations when accessing external APIs are noted over here https://hyperledger.github.io/composer/v0.19/integrating/call-out#consensus-considerations
The workaround I have been using is to set up a second docker container which is not running hyperledger to perform api requests on port 3001, collate the results, then send them over to Hyperledger set up with the REST service on port 3000.