So I'm currently working on a bot to do some Reddit moderation. I typically do db work and stay away from the file system so I believe I might be doing something wrong here.Essentially, the code below declares two variables from the returned values of an async call.// Check for previous contact. let [final_list, add_to_db] = await checkForContact(needs_comments, db); final_list.map(post => { console.log(post); fs.writeFileSync('./stuff.txt', `${post}\r\n`, { flag: 'a' }); }); final_list is an array of Promises that are set to be fulfilled by Promise.all() within the function. Upon returning here, the data should be written to a file. While it does write to the file, it only writes [object Promise] on each line.Am I missing something with the async call here?
Submitted November 30, 2019 at 06:11PM by vulpcod3z
No comments:
Post a Comment