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

93
Views
Resto API, tomar campos de solicitud. resolver

Me quedé en un estupor. Y necesito ayuda.
Descanso la api completa en express

Quiero hacer esto si llega una solicitud del type: reset_password -> Envié un correo electrónico para restablecer mi contraseña (puede ser registro y autenticación)

Pero no sé cómo pasarlo a una consulta. Y eso es, cómo hacerlo. Recorté el código.


 const send = async (req, res) => { const key = req.query.apiKey; const type = req.query.type; const to = req.query.to; if (err) { console.log(err); } else if (rows.length == 0) { res.status(401).json({"apiKey":"error"}) } else { if (email.validate(to)) { sendmail(type, to) } else { res.status(422) } } }

enviar correo:

 const nodemailer = require("nodemailer"); const ejs = require('ejs') const path = require('path') const sendmail = async (type, to, url) => { try { const reset_password = path.join(__dirname, "../template/resetpassword.ejs") const signup_auth = path.join(__dirname, "../template/signupauth.ejs") const sign_in_auth = path.join(__dirname, "../template/signinauth.ejs") const data = await ejs.renderFile(reset_password,signup_auth,sign_in_auth, { to, url } ) let testAccount = await nodemailer.createTestAccount(); // create reusable transporter object using the default SMTP transport let transporter = nodemailer.createTransport({ host: "smtp.ethereal.email", port: 587, secure: false, // true for 465, false for other ports auth: { user: testAccount.user, // generated ethereal user pass: testAccount.pass, // generated ethereal password }, }); const send = await transporter.sendMail({ from: 'dev@test.io', to: to, text: "Hello world?", subject: "test", html: ??? }) console.log("Success send: %s", nodemailer.getTestMessageUrl(send)); }catch (err) { console.log('Error send: ' + err.message); } } module.exports = sendmail;

Ahora tengo una pregunta. ¿Cómo envío una solicitud?: reset_password,signup_auth,sign_in_auth
Es decir, ¿cómo lo paso al tipo: reset_password,signup_auth,sign_in_auth

 http://localhost:3000/api?apiKey=key&type=reset_password,signup_auth,sign_in_auth

¿Cómo lo tomo y lo tramite?
Necesito aceptar type=auth signup reset to api rest Lo siento, tal vez no entendí mi punto correctamente.
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!