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

223
Views
JSON en los datos de la publicación, adjunte la cadena en él

Hola, soy nuevo en JSON y para este proyecto estoy usando POST usando una variable fetch_email dentro de las propiedades del cliente. Actualmente, si envío el valor como {"$email": "sunny@gmail.com"} , se envía. Pero si uso var fetch_email = "sunny@gmail.com" y lo llamo {"$email": fetch_email} , no se envía y arroja un error. ¿Cuál es la mejor manera de llamar a la variable dentro de los const body data para JSON? ¿Puede alguien por favor ayudar en eso?

 const options = { method: 'POST', headers: {Accept: 'text/html', 'Content-Type': 'application/x-www-form-urlencoded'}, body: new searchParams({ data: '{"event": "game mode", "customer_properties": {"$email": fetch_email}}' }) }; fetch('https://thrid_party/api', options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err));
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

No cree cadenas JSON manualmente, use el JSON.stringify() .

 body: new searchParams({ data: JSON.stringify({"event": "game mode", "customer_properties": {"$email": fetch_email}}) })
about 4 years ago · Juan Pablo Isaza Report

0

Prueba esto:

 data: `{"event": "game mode", "customer_properties": {"$email": ${fetch_email}}}`
about 4 years ago · Juan Pablo Isaza Report
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!