Skip to Main Content

Containers, Cloud Native & Kubernetes

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Function in NodeJS Returning Error for Fetching External URL / JSON Data

nickh48226Apr 26 2024

Hello

I wrote a node function to use for custom authorization in my api gateway but when executing it in the OCI functions / integrations I am getting errors on the ‘.then’ of my fetches to the external URL. Below is a sample block that is throwing the error (know this works outside of the OCI function since can run the script standalone on my machine). Anyone have this working with node specifically for getting external JSON data?

Sample Code:

fetch(tokenDiscoveryURL, {
method: 'GET',
headers: {
'Accept': 'application/json',
'User-Agent': 'OCI API GW Runner'
}
})
.then(discoveryResponse => {
//this is needed to satisfy the promise only
logger("Returning the discovery response (promise 1");
return discoveryResponse.json();
})
.then(jsonDisRes => { 
logger("Intro URL: " + jsonDisRes.introspection_endpoint);
logger("Going to introspect the token now");

Then, in the errors, I am getting the below from the logs…

Any help you can give would be appreciated.

Thanks

Nick

Comments

Post Details

Added on Apr 26 2024
1 comment
195 views