Use this tag for questions about features finalized in ECMAScript 2017. Do *not* use this tag if the code in question merely *uses* one of the features, *unless* the feature is cause of the problem.
I know await in loops is highly discouraged. But I'm stuck on a specific case I cannot figure out how to do it efficiently. I want a final output of variable values like this
{
jobId1: [[..], [..], [..], [..]],
jobId2: [[..], [..], [..], [..]]…
I moved to async/await from promises lately. However, I'm uncertain about the try...catch right flow. I have the following example:
const rp = require('request-promise');
const func2 = async () => {
const response1 = await…
how can i use multi promise await in my codes ? when i wanna use second await for second promise it throw an error
function ReadJSONFile() {
return new Promise((resolve, reject) => {
fs.readFile('import.json', 'utf-8', (err, data) => {
…
promises are executed only if you call .then on them
or this is how I learned it.
Async functions are what I understand functions "turned" promises. Do I need to call .then on them each time I want to invoke an async function?
async function…
So, here's the code
let x = await this.storeFileName(fileName);
So, I've declared the storeFileName function as async and I'm also returning a promise and everything till here is fine. But I'm getting an error that says :
SyntaxError: Unexpected…
I am using node v8.0.0. This comes with default async await style of code. I am trying to do some query in parallel and wait for all the promises to resolve then do some operation. But this seems to be not working. Not sure if I am doing anything…
I am trying to compile a list of all customers using the Stripe Node API. I need to make continual fetches 100 customers at a time. I believe that I need to use a Promise within the API call to use async await, but I can't for the life of me figure…
I am trying to capture the response of two service calls within a function. Got to know that async and await will solve this purpose and tried below. Here inside async function ex - I am making a call to users, companies end point and console log is…
In my mocha.js test, I'm calling an async function that throws an error, but the test doesn't fail. It passes and there is an UnhandledPromiseRejectionWarning:
describe('async function', async function () {
it('should fail', async function () {
…
I am really getting a headache trying to make use of the async/await functionality when using for loops. I am using Node.js version: v8.6.0
In short, I am trying to retrieve many rows from a database and then push them all to an array and return…
Can anyone help explain "An object is a member of Object" in ES2017 Language Specs? The sentence shows up in the specs multiple times. For example, in Chapter 4.2 ECMAScript Overview
Properties are containers that hold other objects, primitive…
Basically I'm wondering whether it is possible to redefine a method at class level, not instance level, as sought here.
Just to make clear, also, I want to be able to call the original method (on this) from within the enhanced/replacement method.
I…
I am new in asynchronous programming in javascript. I have two email provider sendgrid and mailgun. i want to send email with one of this then if any error happened, resend email with another one. finally if email sent successfully save into db and…
I have a Express router with specific request handler:
router.post(def.doc_create, handle);
async function docCreate(req, res) {
let metadata = mapper.mapObject(req.body, templates.document_create_rq);
let relatedVers =…