---
title: "Discussion on \"One liner ES6 refactor\" | Hashnode"
description: "Discussion on \"One liner ES6 refactor\". How this function can be refactored to just one line !\nThis is a function returning a function that calls redux's dispatch() function manually.\nexport const fetchUser = () =>\n{\n    return function(dispatch)\n    {\n        axios\n        .get('/api/curr..."
url: "https://hashnode.com/posts/one-liner-es6-refactor/5f813e725841661b519d0153"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [One liner ES6 refactor](https://anjanesh.dev/one-liner-es6-refactor?utm_source=hashnode&utm_medium=feed)

How this function can be refactored to just one line ! This is a function returning a function that calls redux's dispatch() function manually. export const fetchUser = () => { return function(dispatch) { axios .get('/api/curr...

Oct 10, 2020 · 1 min read · anjanesh.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#es6](https://hashnode.com/tag/es6)
-   [#async](https://hashnode.com/tag/async)

## Written by

[Anjanesh Lekshminarayanan](https://hashnode.com/@anjanesh)

@anjanesh · Navi Mumbai, MH

  
[View profile](https://hashnode.com/@anjanesh)

Web UI Engineer

I am a web consultant from Navi Mumbai. Mainly dealt with LAMP stack, now into Django and getting into Laravel and Cloud. Founder of nerul.in and gaali.in

## Responses 1

Markdown supported · ⌘↵ to post

[Darlan Tódero ten Caten](https://hashnode.com/@darlantc)

[Oct 10, 2020](https://hashnode.com/posts/one-liner-es6-refactor/5f813e725841661b519d0153/comment/5f81b5327762251b305d9154)

Please don't. The last code can be small but is very difficult to be readen fast by anyone. Come back to that code in 3 months from now and you will see that you will need a couple of seconds to understand it.

The code must be easy to follow. The first refactor with async/await is perfect, stick with it.

[Anjanesh Lekshminarayanan](https://hashnode.com/@anjanesh)

[Oct 10, 2020](https://hashnode.com/posts/one-liner-es6-refactor/5f813e725841661b519d0153/comment/5f81b5327762251b305d9154#reply-5f81b6af5841661b519d0697)

Yes, I totally agree that #3 is difficult to read even for experienced JavaScript coders. I was just trying to give an example of how sometimes it's possible to condense code to just one line JavaScript. I am going through this tutorial on MERN full-stack by Stephen Grider and came across this.
