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

193
Views
post axios request inside firebase function

I am trying to send a post request with axios, which includes sending the information that comes from another post request. I am implementing it in a firebase function, but I get this error when implementing in visual studio code.

I don't know what is wrong with the code and I tried to make various changes but it doesn't work and the implementation error persists

Error: the functions were not implemented correctly.


    const functions = require("firebase-functions");
    const axios = require("axios");
    const qs = require('querystring');
    const express = require("express");
    const cors = require("cors");
    const app = express();

    const url2 = "----"
const config =  {
    headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
    }};


//app.use(express.json());
//app.use(express.urlencoded({extended: true}));
app.use(cors({ origin: true}));


app.post("/", (req, res)=>{
    // manejo de la ruta
 const enviar = req.body.originalDetectIntentRequest.payload;
 let { 
   ApiVersion,
   SmsSid,
   SmsStatus,
   SmsMessageSid,
   NumSegments,
   ToState,
   From,
   MessageSid,
   AccountSid,
   ToCity,
   FromCountry,
   ToZip,
   FromCity,
   To,
   FromZip,
   ToCountry,
   Body,
   NumMedia,
   FromState 
   } = enviar;

 let requestBody = {
     ApiVersion,
     SmsSid,
     SmsStatus,
     SmsMessageSid,
     NumSegments,
     ToState,
     From,
     MessageSid,
     AccountSid,
     ToCity,
     FromCountry,
     ToZip,
     FromCity,
     To,
     FromZip,
     ToCountry,
     Body,
     NumMedia,
     FromState 
   };

 axios.post(url2, qs.stringify(requestBody), config)
   .then(function (response) {
   // ... hacemos otras cosas
   res.status(200).json({ok: true, msg:"mensaje enviado correctamente"});
   })
   .catch(error => {
   // manejamos el error
   console.error(error);
   res.status(500).json({
   error: "Upps, algo fue mal"
   });

   });


});



module.exports.mesn = functions.https.onRequest(app);

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!