ecmascript 6 - How to remove returns in the following .then() functions? -


i want remove 1 or 2 returns in following .then() functions:

 return store.findparent(to.params.id).then((project) => {     return store.findbyparent('project', project).then((result) => {       return {         project: project.tojson(),         tasks: result       }     })   }) 

i tried this:

  return store.findparent(to.params.id).then((project) => ({     store.findbyparent('project', project).then((result) => {       project: project.tojson(),       tasks: store.findlistbyparent('project', project)     })   })) 

but

parsing error: unexpected identifier @ tasks: store.findlistbyparent

what's proper way of doing it?

you want rid of braces , parenthesis when using concise form of arrow functions - unless want return object literal.

return store.findparent(to.params.id).then(project =>     store.findbyparent('project', project).then(result =>          ({             project: project.tojson(),             tasks: result         })     ) ); 

what have object literal .findbyparent… syntax error in property name.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -