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

107
Views
¿Cómo devolver la respuesta al front-end desde la solicitud posterior en el nodo?

Estoy tratando de hacer una solicitud POST desde el nodo después de una solicitud POST del cliente y devolver la respuesta del servidor al cliente. ¿Cómo puedo pasar la respuesta de la publicación desde el backend a la solicitud de publicación originalmente desde la interfaz? Puedo acceder a la promesa en el ámbito asíncrono, pero ¿cómo puedo... err... empujarlo/lanzarlo hacia el extremo del cliente? Gracias.

 async function sendToken() { return await axios .post("http://localhost:3001/Recaptcha", {token: token}) .then((res) => { console.log('client recaptcha sent'); return res; }) .catch((err) => console.log(err, 'recaptcha not sent')); }
 app.post('/Recaptcha', (req, res) => { let p = new Promise((resolve, reject) => { // just to see if it would work console.log(req.body.token) const token = req.body.token const secret = process.env.secret async function validateRecaptcha() { return await axios .post(`https://www.google.com/recaptcha/api/siteverify?secret=${secret}&response=${token}`) .then((res) => { console.log('server recaptcha sent'); resolve(res); return res; }) .catch((err) => console.log(err, 'recaptcha not sent')); } validateRecaptcha().then((res) => { console.log("recaptcha data:", res.data); //if (res.data.success === true) { // *if I could do this everything would work* // res.send("HELLO") //} p.then((result) => { // I can access a promise result, but how do I push it... up? console.log("p:", result.data) res.send(result.data) // res.send is not a function error }) }) console.log(validateRecaptcha.res) // undefined, pending promise if (res.data.success === true) { // *how do I access this data to send to front?* res.send("HELLO") } }) });
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!