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

InoL Apr 29 2024

How doc gen treats nulls values?

You have to be more specific. Are your referring to the pre-built Document Generator function?

If so:

When my query return null in some columns

What is the JSON that is generated?

You should always include the element in the JSON, with an empty value. Don't leave it out.

Francois Robert-Oracle Jan 8 2025 — edited on Jan 8 2025

Since September 2024, when a tag has no corresponding value in the JSON data or the value is null, the tag is replaced by an empty string.

See the September Release Notes

1 - 2

Post Details

Added on Apr 26 2024
1 comment
179 views