---
title: "Discussion on \"Update State After API Response React!!!\" | Hashnode"
description: "Discussion on \"Update State After API Response React!!!\". Have you ever wondered why immediately after updating the state if it is logged, the value is undefined??\n  const fetchAPI = async () => {\n    const res = await axios.get(\"https://catfact.ninja/fact\");\n    setData((previousData) => ({ ...previousData..."
url: "https://hashnode.com/posts/update-state-after-api-response-react/63806a8e3e6bc285c76180db"
---

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

Discussion

# [Update State After API Response React!!!](https://kheersagar.hashnode.dev/update-state-after-api-response-react?utm_source=hashnode&utm_medium=feed)

Have you ever wondered why immediately after updating the state if it is logged, the value is undefined?? const fetchAPI = async () => { const res = await axios.get("https://catfact.ninja/fact"); setData((previousData) => ({ ...previousData...

Nov 25, 2022 · 2 min read · kheersagar.hashnode.dev  
Updated Nov 30, 2022  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)
-   [#programming-tips](https://hashnode.com/tag/programming-tips)
-   [#reacthooks](https://hashnode.com/tag/reacthooks)

## Written by

[Kheersagar Parja](https://hashnode.com/@Kheersagar)

@Kheersagar

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

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
