Error: How to serialize data from getStaticProps : Next.js

Add JSON.stringify when calling an asynchronous function that returns an object. Try modifying your getStaticProps function like this. export async function getStaticProps() { const profiles = await getAllBusinessProfiles(); const allProfiles = JSON.stringify(profiles) return { props: { allProfiles } }; } The JSON.stringify() method converts a JavaScript object or value to a JSON string, optionally replacing … Read more

ES6 syntax import Electron (require..)

It seems imports are not implemented in either Node 6 or Chrome 51 so Electron also does not support them, according to this post: https://discuss.atom.io/t/does-electron-support-es6/19366/18 And also the last electron doc doesn’t use imports, they use destructuring syntax: const { BrowserWindow } = require(‘electron’).remote // or const { remote } = require(‘electron’) const { BrowserWindow … Read more

using the … spread syntax in javascript es6 named exports

Object rest spread is stage 3 proposal and not a part of any spec (will probably be included in ES2018). More importantly, export has syntax that mimics existing JS syntax but doesn’t interpret { … } as an expression. export syntax was strictly defined because ES2015 modules are supposed to be statically analyzed. This is … Read more

Will const and let make the IIFE pattern unnecessary?

Yes, blocks are going to replace IEFEs, as soon as block-scoped declarations (functions, let/const/class) become widely adopted. You need a scope, e.g. for a closure? Here you have a block, be it a loop body or just part of a statement list. However, there is still one application of IEFEs that blocks cannot replace: the … Read more

Spread Syntax ES6

In your example given, there is essentially no difference between the two .concat is significantly more efficient: http://jsperf.com/spread-into-array-vs-concat because … (spread) is merely syntax sugar on top of more fundamental underlying syntax that explicitly iterates over indexes to expand the array. Spread allows sugared syntax on top of more clunky direct array manipulation To expand … Read more

Is it possible to call a super setter in ES6 inherited classes?

class Y extends X { constructor(name) { super(name); } set name(name) { super.name = name; this._name += “Y”; } } will override the name properly with an accessor for just the setter, with no getter. That means your y.name === “hiXY” will fail because y.name will return undefined because there is no getter for name. … Read more