How to use headers with netlify functions

so i am trying to use netlify functions to call an api and i’ve discovered that the request returns as ‘undefined’ when the api needs headers but it is successful when i call api’s that dont require headers. i wanted to know if anyone else has this issue and how to solve it.

const axios = require("axios");

exports.handler = async function (event, context) {
    const { id } = event.queryStringParameters;
    const url = `${id}`
    try {
      const {data} = axios.get(url, {
        headers: {
         "x-rapidapi-host": "",
         "x-rapidapi-key": `${process.env.REACT_APP_RAPID_KEY}`
      return {
        statusCode: 200,
        body: JSON.stringify(data),
    } catch (err) {
        const {statusCode, statusText, headers, data} = err.response;
      return {
        statusCode: 500,
        body: JSON.stringify({ statusCode, statusText, headers, data }),

Hey there, @binatari :wave:

Welcome to the Netlify Forums! Thanks so much for reaching out. Can you share you site name, your functions name, and your project repo with us?