Save Async/Await response on a variable

1) Return something from your asyncExample function const asyncExample = async () => { const result = await axios(users) return result } 2) Call that function and handle its returned Promise: ;(async () => { const users = await asyncExample() console.log(users) })() Here’s why should you handle it like this: You can’t do top-level await … Read more

Importing modules using ES6 syntax and dynamic path [duplicate]

No, this is not possible. ES6 modules need to be able to statically resolve their dependencies, without executing module code, so that import statements do work reliably. The module specifier must be a string literal. However, the module loader of your choice should support dynamic loading of modules with variable names. You wouldn’t be able … Read more

How to make function parameter constant in JavaScript?

Function parameters will stay mutable bindings (like var) in ES6, there’s nothing you can do against that. Probably the best solution you get is to destructure the arguments object in a const initialisation: function hasConstantParameters(const a, const b, const c, …) { // not possible … } function hasConstantParameters() { const [a, b, c, …] … Read more

Official information on `arguments` in ES6 Arrow functions?

Chrome, FF, and node seem to be wrong here, Babel is correct: Arrow functions do not have an own arguments binding in their scope; no arguments object is created when calling them. looking for official docs here Arrow function expressions evaluate to functions that have their [[ThisMode]] set to lexical, and when such are called … Read more

How to minify ES6 functions with gulp-uglify?

You can leverage gulp-babel as such… const gulp = require(‘gulp’); const babel = require(‘gulp-babel’); const uglify = require(‘gulp-uglify’); gulp.task(‘minify’, () => { return gulp.src(‘src/**/*.js’) .pipe(babel({ presets: [‘es2015’] })) .pipe(uglify()) // […] }); This will transpile your es6 early in the pipeline and churn out as widely supported “plain” javascript by the time you minify. May … Read more

Cleaning Unwanted Fields From GraphQL Responses

There are three ways of doing this First way Update the client parameter like this it will omit the unwanted fields in graphql. apollo.create({ link: http, cache: new InMemoryCache({ addTypename: false }) }); Second Way By using the omit-deep package and use it as a middleware const cleanTypeName = new ApolloLink((operation, forward) => { if … Read more

When will ECMAScript v 6 become standard [closed]

As of June 2015: here it is! http://www.ecma-international.org/ecma-262/6.0 As of June 2014: The GA will vote on approving it as a Ecma standard at their June 2015 meeting. At the time of writing (March 2013): A sixth edition of the standard is currently under development with a target date of December 2013 for completion. http://ecma-international.org/memento/TC39-M.htm