createAsyncThunk
line-clamp to trim lines of textMaster the CSS line-clamp property. Learn how to truncate text lines, ensure cross-browser compatibility, and avoid hidden UX pitfalls when designing modern web layouts.

Discover seven custom React Hooks that will simplify your web development process and make you a faster, better, more efficient developer.

Promise.all still relevant in 2025?In 2025, async JavaScript looks very different. With tools like Promise.any, Promise.allSettled, and Array.fromAsync, many developers wonder if Promise.all is still worth it. The short answer is yes — but only if you know when and why to use it.

Discover what’s new in The Replay, LogRocket’s newsletter for dev and engineering leaders, in the October 29th issue.
Would you be interested in joining LogRocket's developer community?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up now
7 Replies to "Using Redux Toolkit’s <code>createAsyncThunk</code>"
Thanks so much
You just saved me man
Thanks a lot
You’re welcome man. Glad I could help (:
While you correctly describe the payloadCreator as the second parameter of the async request, your use of the pseudocode “async (thunkAPI)” misleadingly may guide a reader into believing the thunkAPI is first parameter. (I certainly was fooled.) Perhaps clearer pseudocode would be “async (_, thunkAPI)”?
While redux might be a hard topic to understand, you made it easy to understand.
Good afternoon!
Excellent article, I learned a lot, but I didn’t understand how you use the getPosts function and you didn’t export it from the file, where am I going wrong?
You forgot an “export” in front of the definition of the getPosts createAsyncThunk. That’s how you can run it as a function within the dispatch() operation.
I thought I had a fundamental misunderstanding of Redux for a second there. Finally figured out it was a typo when I checked out the official docs.
https://redux-toolkit.js.org/api/createAsyncThunk
We’ve now fixed this typo — thanks for catching that, Jared!