Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

376
Views
do netlify functions not work with axios headers?

ok so i'm trying to make an api call using netlify functions and if i try calling another api that does not require headers it works perfectly but when i include headers the promise returns as 'undefined'

const axios = require("axios");

exports.handler = async function (event, context) {
 
   const { id } = event.queryStringParameters;
   const url = `https://youtube-mp36.p.rapidapi.com/dl?id=${id}`
   try {
     const {data} = axios.get(url, {
       headers: {
        "x-rapidapi-host": "youtube-mp36.p.rapidapi.com",
        "x-rapidapi-key": `${process.env.REACT_APP_RAPID_KEY}`
        }
      });
      console.log(data)
     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 }),
     };
   }
 };

this is my code so far any help would honestly be appreciated

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!