I’ve searched all over for this information and can’t find it.
For a Netlify Function that uses node-fetch
to GET
data from a third party API endpoint, how can one debug (inspect, see, view) the Request
headers AS SENT by Netlify to the API from the function?
I’m trying to set some headers the API wants and I don’t think they are being set correctly, and there is no way to tell since I can’t inspect the request. I could mock the third-party API using Postman, but I’d prefer to know if there is a direct Netlify way.
Note: the function does not require a build step, it’s just a simple zip-it-and-ship-it using Netlify Dev. Example code:
const fetch = require('node-fetch');
const { API_KEY, API_BASE } = process.env;
exports.handler = async function(event, context) {
const { endpoint } = event.queryStringParameters;
const url = `${API_BASE}${endpoint}?access_key=${API_KEY}`;
try {
const res = await fetch(url, {
headers: {
'accept': 'application/json',
'if-modified-since':' foo',
'if-none-match': 'bar',
}
});
..snipp...rest of code
Thank you