Questions tagged [ecmascript-2017]

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.

Proposals finalized in 2017 include:

387 questions
0
votes
3 answers

efficient use of async/await

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: [[..], [..], [..], [..]]…
Faysal Ahmed
  • 1,592
  • 13
  • 25
0
votes
1 answer

Node.js async/await try catch flow - best practice

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…
wizard
  • 583
  • 2
  • 9
  • 26
0
votes
1 answer

nodejs how to use multiple await promises

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) => { …
user8675491
0
votes
1 answer

Async functions - require .then to execute them?

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…
Han Che
  • 8,239
  • 19
  • 70
  • 116
0
votes
3 answers

js async/await throws error on using this keyword

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…
Shiva Teja
  • 417
  • 4
  • 16
0
votes
0 answers

async await, using Promise.all not working

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…
undefined
  • 3,464
  • 11
  • 48
  • 90
0
votes
2 answers

Fetching all stripe customers with async await

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…
user4815162342
  • 1,638
  • 2
  • 17
  • 23
0
votes
1 answer

Fetching return value from async function

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…
Suresh K
  • 21
  • 4
0
votes
2 answers

Async test with inner async function should fail

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 () { …
GilZ
  • 6,418
  • 5
  • 30
  • 40
0
votes
2 answers

Having Async/Await Promise troubles - Javascript/Nodejs

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…
nd510
  • 113
  • 4
0
votes
1 answer

Async Functions are not invoked sequentially

I have three async functions: getAccounts = async () => { try { const result = await someAsyncJob(); ... } catch(err) { ... } } getPages = async () => { try { const result = await someAsyncJob(); …
modernator
  • 4,341
  • 12
  • 47
  • 76
0
votes
2 answers

"An object is a member of Object" in ES2017 Specs

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…
Dustin Sun
  • 5,292
  • 9
  • 49
  • 87
0
votes
2 answers

"Enhance" existing JS class in ECMAScript 2017 (Firefox v55)?

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…
mike rodent
  • 14,126
  • 11
  • 103
  • 157
0
votes
2 answers

how to use asynchronous and synchronous programming in right time

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…
amir
  • 2,443
  • 3
  • 22
  • 49
0
votes
0 answers

UnhandledPromiseRejectionWarning on handler method abstraction wrapper

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 =…
greengold
  • 1,184
  • 3
  • 18
  • 43