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

266
Views
¿Por qué esta función regresa indefinida cuando sé que no lo es?
function redditCall(subreddit) { https.get(`https://www.reddit.com/r/${subreddit}/top.json`, (resp) => { let data = " "; resp.on("data", (chunk) => { data += chunk; }); resp.on("end", () => { let json = JSON.parse(data); if (json.message === "Not Found" || json.message) { console.log("That subreddit was not found!"); } else { if (!json.data.children[0].data.secure_media || json.data.children[0].data.secure_media === null) { let postAttachment = json.data.children[0].data.url_overridden_by_dest; // console.log(`That post has an picture attachment: ${postAttachment}`); console.log(postAttachment); // returns the correct link return postAttachment; // Picture Post } else { let postAttachment = json.data.children[0].data.secure_media.reddit_video.scrubber_media_url; //console.log(`That post has a video attachment: ${postAttachment}`); return postAttachment; // Video Post } } }); }); }

Como dice el título, por alguna razón, esta función regresa indefinida cuando he iniciado sesión en postAttachment en la consola y muestra la cadena correcta, pero por alguna razón, cuando devuelvo postAttachment, dice indefinido. Intenté hacer .toString() y simplemente se muestra indefinido cuando lo devuelvo cuando sé con certeza que no lo es.

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!