BeFreed
    Categories>Technology>API calls and the mistake that breaks your forms

    API calls and the mistake that breaks your forms

    28 min
    |
    |
    Apr 7, 2026
    TechnologyEducationProductivity

    Relying on onClick for API calls often breaks form behavior. Learn why Fetch handles errors differently than Axios and how to manage status codes.

    API calls and the mistake that breaks your forms

    Best quote from API calls and the mistake that breaks your forms

    “

    Controlled components are what separate professional apps from amateur ones because they allow for real-time feedback. React should be the single source of truth, creating a perfect loop between the state and the user's input.

    ”

    This audio lesson was created by a BeFreed community member

    Input question

    Backend - API Development: API fundamentalsYour first API endpointHTML formsHTML inputsReact controlled formsAPI callsAxios (HTTP client)HTTP status codesError handling & messagesOptional chaining operator

    Host voices
    Lenaplay
    Milesplay
    Learning style
    Deep
    Knowledge sources
    Developing Backbone.js Applications
    Two Scoops of Django
    Building Microservices
    Kubernetes Patterns
    Getting Real: The smarter, faster, easier way to build a successful web application
    Python

    Frequently Asked Questions

    Using "onSubmit" on the HTML form element allows you to tap into the web’s natural behavior, such as triggering a submission when a user hits the "Enter" key. It also enables automatic browser validation features. When using this method, it is essential to call "event.preventDefault()" to stop the page from reloading, which would otherwise cause the application to lose its current state.

    A major misconception is that Fetch and Axios handle server errors the same way. Fetch only rejects a promise if there is a network failure; it actually considers HTTP 500 server crashes or 404 errors as "successful" resolutions. Axios, however, is designed to automatically treat any status code outside the 2xx range as an error, allowing developers to catch server-side issues directly within a "catch" block.

    Controlled components are form elements where React acts as the "single source of truth" for the input's value. Instead of the browser's DOM holding the text, the value is tied to a specific piece of React state, and an "onChange" handler updates that state with every keystroke. This approach is preferred because it allows for real-time feedback, such as instant field validation, password strength meters, or automatic phone number formatting.

    When a request fails backend validation, FastAPI returns an HTTP 422 Unprocessable Entity error. The response body contains a "detail" array that specifies the exact location of the error, such as a specific field name, and a message explaining the issue. Developers can map these specific server-side errors back to the React form state to display helpful, inline error messages directly under the relevant input fields.

    When an API call begins, developers typically set a "loading" state to true to disable the submit button and prevent duplicate entries. If the loading state is only set to false in the success path, a server error could leave the button disabled forever, trapping the user. Using a "finally" block ensures that the loading state is reset to false regardless of whether the call succeeded or failed, allowing the user to try again.

    Discover more

    Master API Fundamentals and Postman Skills

    Master API Fundamentals and Postman Skills

    LEARNING PLAN

    Master API Fundamentals and Postman Skills

    This learning plan is essential for developers and QA engineers looking to bridge the gap between basic coding and professional backend engineering. It provides a comprehensive roadmap from foundational HTTP concepts to advanced microservices patterns and automated testing in Postman.

    2 h 20 m•4 Sections
    Design successful apps that users love

    Design successful apps that users love

    LEARNING PLAN

    Design successful apps that users love

    In today's competitive app market, user experience often determines which products thrive and which fail. This learning plan equips designers and product managers with essential UX principles and psychological insights to create apps that users genuinely want to use repeatedly.

    2 h 16 m•4 Sections
    Agentic Ai app builder

    Agentic Ai app builder

    LEARNING PLAN

    Agentic Ai app builder

    As AI evolves from passive chat interfaces to active problem-solvers, mastering agentic systems is becoming a critical skill for modern developers and entrepreneurs. This plan is ideal for non-technical innovators and aspiring AI builders who want to create autonomous applications without deep coding knowledge.

    4 h 2 m•4 Sections
    deep react knowledge

    deep react knowledge

    LEARNING PLAN

    deep react knowledge

    React continues to dominate the frontend development landscape, but mastering its core concepts and advanced patterns is essential for building professional-grade applications. This learning plan is ideal for developers who have basic JavaScript knowledge and want to become proficient React engineers capable of building complex, performant applications.

    2 h 22 m•3 Sections
    Learn about AI

    Learn about AI

    LEARNING PLAN

    Learn about AI

    As artificial intelligence reshapes every industry, understanding its technical foundations and ethical boundaries is essential for modern professionals. This path is ideal for aspiring developers and tech-curious individuals looking to transition from basic theory to building functional, responsible AI systems.

    1 h 52 m•4 Sections
    Break unhealthy attachments

    Break unhealthy attachments

    LEARNING PLAN

    Break unhealthy attachments

    Unhealthy attachments and codependency can trap you in cycles of emotional dependence and unfulfilling relationships. This learning plan helps anyone struggling with relationship patterns that diminish their sense of self, providing practical tools to break free and build healthier connections.

    1 h 43 m•4 Sections
    Viral lyric-based emotional messaging app UI

    Viral lyric-based emotional messaging app UI

    LEARNING PLAN

    Viral lyric-based emotional messaging app UI

    This learning plan is essential for designers and product managers looking to break into the competitive social media space by leveraging emotional resonance. It combines high-level UI/UX fundamentals with the specific mechanics of viral growth and music-driven storytelling.

    3 h 12 m•4 Sections
    Build dog grooming & yoga web/app guide

    Build dog grooming & yoga web/app guide

    LEARNING PLAN

    Build dog grooming & yoga web/app guide

    This comprehensive guide is designed for aspiring developers and entrepreneurs looking to merge wellness and pet care into a digital platform. It bridges the gap between technical execution and niche industry expertise, making it ideal for those wanting to build a specialized, professional-grade application.

    2 h 23 m•4 Sections

    From Columbia University alumni built in San Francisco

    BeFreed Brings Together A Global Community Of 1,000,000 Curious Minds
    See more on how BeFreed is discussed across the web

    "Instead of endless scrolling, I just hit play on BeFreed. It saves me so much time."

    @Moemenn
    platform
    star
    star
    star
    star
    star

    "I never knew where to start with nonfiction—BeFreed’s book lists turned into podcasts gave me a clear path."

    @Chloe, Solo founder, LA
    platform
    comments
    12
    likes
    117

    "Perfect balance between learning and entertainment. Finished ‘Thinking, Fast and Slow’ on my commute this week."

    @Raaaaaachelw
    platform
    star
    star
    star
    star
    star

    "Crazy how much I learned while walking the dog. BeFreed = small habits → big gains."

    @Matt, YC alum
    platform
    comments
    12
    likes
    108

    "Reading used to feel like a chore. Now it’s just part of my lifestyle."

    @Erin, Investment Banking Associate , NYC
    platform
    comments
    254
    likes
    17

    "Feels effortless compared to reading. I’ve finished 6 books this month already."

    @djmikemoore
    platform
    star
    star
    star
    star
    star

    "BeFreed turned my guilty doomscrolling into something that feels productive and inspiring."

    @Pitiful
    platform
    comments
    96
    likes
    4.5K

    "BeFreed turned my commute into learning time. 20-min podcasts are perfect for finishing books I never had time for."

    @SofiaP
    platform
    star
    star
    star
    star
    star

    "BeFreed replaced my podcast queue. Imagine Spotify for books — that’s it. 🙌"

    @Jaded_Falcon
    platform
    comments
    201
    thumbsUp
    16

    "It is great for me to learn something from the book without reading it."

    @OojasSalunke
    platform
    star
    star
    star
    star
    star

    "The themed book list podcasts help me connect ideas across authors—like a guided audio journey."

    @Leo, Law Student, UPenn
    platform
    comments
    37
    likes
    483

    "Makes me feel smarter every time before going to work"

    @Cashflowbubu
    platform
    star
    star
    star
    star
    star

    From Columbia University alumni built in San Francisco

    BeFreed Brings Together A Global Community Of 1,000,000 Curious Minds
    See more on how BeFreed is discussed across the web

    "Instead of endless scrolling, I just hit play on BeFreed. It saves me so much time."

    @Moemenn
    platform
    star
    star
    star
    star
    star

    "I never knew where to start with nonfiction—BeFreed’s book lists turned into podcasts gave me a clear path."

    @Chloe, Solo founder, LA
    platform
    comments
    12
    likes
    117

    "Perfect balance between learning and entertainment. Finished ‘Thinking, Fast and Slow’ on my commute this week."

    @Raaaaaachelw
    platform
    star
    star
    star
    star
    star

    "Crazy how much I learned while walking the dog. BeFreed = small habits → big gains."

    @Matt, YC alum
    platform
    comments
    12
    likes
    108

    "Reading used to feel like a chore. Now it’s just part of my lifestyle."

    @Erin, Investment Banking Associate , NYC
    platform
    comments
    254
    likes
    17

    "Feels effortless compared to reading. I’ve finished 6 books this month already."

    @djmikemoore
    platform
    star
    star
    star
    star
    star

    "BeFreed turned my guilty doomscrolling into something that feels productive and inspiring."

    @Pitiful
    platform
    comments
    96
    likes
    4.5K

    "BeFreed turned my commute into learning time. 20-min podcasts are perfect for finishing books I never had time for."

    @SofiaP
    platform
    star
    star
    star
    star
    star

    "BeFreed replaced my podcast queue. Imagine Spotify for books — that’s it. 🙌"

    @Jaded_Falcon
    platform
    comments
    201
    thumbsUp
    16

    "It is great for me to learn something from the book without reading it."

    @OojasSalunke
    platform
    star
    star
    star
    star
    star

    "The themed book list podcasts help me connect ideas across authors—like a guided audio journey."

    @Leo, Law Student, UPenn
    platform
    comments
    37
    likes
    483

    "Makes me feel smarter every time before going to work"

    @Cashflowbubu
    platform
    star
    star
    star
    star
    star

    "Instead of endless scrolling, I just hit play on BeFreed. It saves me so much time."

    @Moemenn
    platform
    star
    star
    star
    star
    star

    "I never knew where to start with nonfiction—BeFreed’s book lists turned into podcasts gave me a clear path."

    @Chloe, Solo founder, LA
    platform
    comments
    12
    likes
    117

    "Perfect balance between learning and entertainment. Finished ‘Thinking, Fast and Slow’ on my commute this week."

    @Raaaaaachelw
    platform
    star
    star
    star
    star
    star

    "Crazy how much I learned while walking the dog. BeFreed = small habits → big gains."

    @Matt, YC alum
    platform
    comments
    12
    likes
    108

    "Reading used to feel like a chore. Now it’s just part of my lifestyle."

    @Erin, Investment Banking Associate , NYC
    platform
    comments
    254
    likes
    17

    "Feels effortless compared to reading. I’ve finished 6 books this month already."

    @djmikemoore
    platform
    star
    star
    star
    star
    star

    "BeFreed turned my guilty doomscrolling into something that feels productive and inspiring."

    @Pitiful
    platform
    comments
    96
    likes
    4.5K

    "BeFreed turned my commute into learning time. 20-min podcasts are perfect for finishing books I never had time for."

    @SofiaP
    platform
    star
    star
    star
    star
    star

    "BeFreed replaced my podcast queue. Imagine Spotify for books — that’s it. 🙌"

    @Jaded_Falcon
    platform
    comments
    201
    thumbsUp
    16

    "It is great for me to learn something from the book without reading it."

    @OojasSalunke
    platform
    star
    star
    star
    star
    star

    "The themed book list podcasts help me connect ideas across authors—like a guided audio journey."

    @Leo, Law Student, UPenn
    platform
    comments
    37
    likes
    483

    "Makes me feel smarter every time before going to work"

    @Cashflowbubu
    platform
    star
    star
    star
    star
    star

    "Instead of endless scrolling, I just hit play on BeFreed. It saves me so much time."

    @Moemenn
    platform
    star
    star
    star
    star
    star

    "I never knew where to start with nonfiction—BeFreed’s book lists turned into podcasts gave me a clear path."

    @Chloe, Solo founder, LA
    platform
    comments
    12
    likes
    117

    "Perfect balance between learning and entertainment. Finished ‘Thinking, Fast and Slow’ on my commute this week."

    @Raaaaaachelw
    platform
    star
    star
    star
    star
    star

    "Crazy how much I learned while walking the dog. BeFreed = small habits → big gains."

    @Matt, YC alum
    platform
    comments
    12
    likes
    108

    "Reading used to feel like a chore. Now it’s just part of my lifestyle."

    @Erin, Investment Banking Associate , NYC
    platform
    comments
    254
    likes
    17

    "Feels effortless compared to reading. I’ve finished 6 books this month already."

    @djmikemoore
    platform
    star
    star
    star
    star
    star

    "BeFreed turned my guilty doomscrolling into something that feels productive and inspiring."

    @Pitiful
    platform
    comments
    96
    likes
    4.5K

    "BeFreed turned my commute into learning time. 20-min podcasts are perfect for finishing books I never had time for."

    @SofiaP
    platform
    star
    star
    star
    star
    star

    "BeFreed replaced my podcast queue. Imagine Spotify for books — that’s it. 🙌"

    @Jaded_Falcon
    platform
    comments
    201
    thumbsUp
    16

    "It is great for me to learn something from the book without reading it."

    @OojasSalunke
    platform
    star
    star
    star
    star
    star

    "The themed book list podcasts help me connect ideas across authors—like a guided audio journey."

    @Leo, Law Student, UPenn
    platform
    comments
    37
    likes
    483

    "Makes me feel smarter every time before going to work"

    @Cashflowbubu
    platform
    star
    star
    star
    star
    star
    1.5K Ratings4.7
    Start your learning journey, now
    BeFreed App
    BeFreed

    Learn Anything, Personalized

    DiscordLinkedIn
    Featured book summaries
    Crucial ConversationsThe Perfect MarriageInto the WildNever Split the DifferenceAttachedGood to GreatSay Nothing
    Trending categories
    Self HelpCommunication SkillRelationshipMindfulnessPhilosophyInspirationProductivity
    Celebrities' reading list
    Elon MuskCharlie KirkBill GatesSteve JobsAndrew HubermanJoe RoganJordan Peterson
    Award winning collection
    Pulitzer PrizeNational Book AwardGoodreads Choice AwardsNobel Prize in LiteratureNew York TimesCaldecott MedalNebula Award
    Featured Topics
    ManagementAmerican HistoryWarTradingStoicismAnxietySex
    Best books by Year
    2025 Best Non Fiction Books2024 Best Non Fiction Books2023 Best Non Fiction Books
    Featured authors
    Chimamanda Ngozi AdichieGeorge OrwellO. J. SimpsonBarbara O'NeillWinston ChurchillCharlie Kirk
    BeFreed vs other apps
    BeFreed vs. Other Book Summary AppsBeFreed vs. ElevenReaderBeFreed vs. ReadwiseBeFreed vs. Anki
    Learning tools
    Knowledge VisualizerAI Podcast Generator
    Information
    About Usarrow
    Pricingarrow
    FAQarrow
    Blogarrow
    Careerarrow
    Partnershipsarrow
    Ambassador Programarrow
    Directoryarrow
    BeFreed
    Try now
    © 2026 BeFreed
    Term of UsePrivacy Policy
    BeFreed

    Learn Anything, Personalized

    DiscordLinkedIn
    Featured book summaries
    Crucial ConversationsThe Perfect MarriageInto the WildNever Split the DifferenceAttachedGood to GreatSay Nothing
    Trending categories
    Self HelpCommunication SkillRelationshipMindfulnessPhilosophyInspirationProductivity
    Celebrities' reading list
    Elon MuskCharlie KirkBill GatesSteve JobsAndrew HubermanJoe RoganJordan Peterson
    Award winning collection
    Pulitzer PrizeNational Book AwardGoodreads Choice AwardsNobel Prize in LiteratureNew York TimesCaldecott MedalNebula Award
    Featured Topics
    ManagementAmerican HistoryWarTradingStoicismAnxietySex
    Best books by Year
    2025 Best Non Fiction Books2024 Best Non Fiction Books2023 Best Non Fiction Books
    Learning tools
    Knowledge VisualizerAI Podcast Generator
    Featured authors
    Chimamanda Ngozi AdichieGeorge OrwellO. J. SimpsonBarbara O'NeillWinston ChurchillCharlie Kirk
    BeFreed vs other apps
    BeFreed vs. Other Book Summary AppsBeFreed vs. ElevenReaderBeFreed vs. ReadwiseBeFreed vs. Anki
    Information
    About Usarrow
    Pricingarrow
    FAQarrow
    Blogarrow
    Careerarrow
    Partnershipsarrow
    Ambassador Programarrow
    Directoryarrow
    BeFreed
    Try now
    © 2026 BeFreed
    Term of UsePrivacy Policy

    Key Takeaways

    1

    Stop Breaking Your API Calls

    0:00
    0:13
    0:28
    0:36
    0:50
    2

    The Two Layers of Form Mastery

    1:01
    1:25
    1:39
    2:06
    2:13
    2:40
    3:04
    3:20
    3:29
    3:45
    4:27
    4:40
    3

    Navigating the Axios Advantage

    5:10
    5:31
    5:51
    6:11
    6:29
    1:39
    7:04
    7:11
    7:36
    7:59
    8:24
    8:42
    4

    The FastAPI Validation Handshake

    9:07
    9:27
    9:43
    9:59
    10:13
    1:39
    10:50
    11:07
    11:33
    11:50
    12:09
    12:19
    12:35
    5

    Mastering HTML Inputs and Their Quirks

    12:52
    13:07
    13:17
    13:36
    13:50
    14:09
    14:26
    14:45
    1:39
    15:06
    15:20
    15:33
    15:45
    16:05
    6

    The Async/Await Revolution in React

    16:14
    16:28
    1:39
    5:51
    17:01
    17:23
    17:38
    17:53
    18:02
    18:25
    18:43
    18:59
    19:12
    7

    Error Handling Strategies for a Better UX

    19:22
    19:36
    19:52
    20:06
    20:19
    1:39
    20:47
    20:58
    21:06
    21:18
    21:29
    21:39
    22:01
    8

    Practical Playbook for Your First Endpoint

    22:10
    22:21
    22:34
    22:48
    22:59
    23:14
    23:26
    23:36
    23:47
    14:09
    4:40
    9

    Security and Performance Considerations

    24:21
    24:35
    24:51
    25:01
    25:15
    25:29
    25:41
    1:39
    26:08
    26:15
    26:21
    10

    Closing Reflection & Wrap-up

    26:31
    14:09
    27:01
    27:17
    27:26
    27:42
    1:39
    27:56
    28:07
    28:13
    19:12
    28:39

    More like this

    React Data Fetching: A Recipe for Resilient Apps book cover
    Developing Backbone.js ApplicationsKubernetes PatternsTwo Scoops of DjangoPython Cookbook
    24 sources
    React Data Fetching: A Recipe for Resilient Apps
    Master the essential pattern for handling data, loading, and error states in React. Learn to use useEffect for fetching podcast data while building a foolproof UI that never leaves users in the dark.
    23 min
    How useEffect Syncs React with the Outside World book cover
    Developing Backbone.js ApplicationsHookedClean CodeSystem Design Interview
    25 sources
    How useEffect Syncs React with the Outside World
    Struggling with infinite loops or double API calls? Learn how to use the dependency array and cleanup functions to keep your UI in sync without the bugs.
    24 min
    HTTP, APIs, and JSON for Vibe Coders book cover
    Developing Backbone.js ApplicationsPythonBuilding Wireless Sensor NetworksSoftware Engineering
    16 sources
    HTTP, APIs, and JSON for Vibe Coders
    Stop losing user data to local state. Learn how to use HTTP and JSON to connect your frontend to a database so your app actually remembers its data.
    23 min
    React State Mistakes: Stop Storing Derived Data book cover
    Developing Backbone.js ApplicationsTwo Scoops of DjangoRefactoringClean Code
    25 sources
    React State Mistakes: Stop Storing Derived Data
    Managing filtered lists in state often leads to bugs and extra renders. Learn why calculating values on the fly keeps your UI in sync and your code clean.
    22 min
    Why JSX Isn't Just HTML book cover
    Developing Backbone.js ApplicationsEffective JavaPythonPython Cookbook
    22 sources
    Why JSX Isn't Just HTML
    Struggling with React syntax errors? Learn why className and self-closing tags matter so you can write cleaner JavaScript and build better interfaces.
    24 min
    React 19 data fetching and the new use hook book cover
    Developing Backbone.js ApplicationsHookedClean CodeKubernetes Patterns
    21 sources
    React 19 data fetching and the new use hook
    Stop fighting boilerplate and manual loading states. Learn how the React 19 use hook simplifies server state so you can write cleaner, faster code.
    13 min
    Fail fast, fail often book cover
    Fail fast, fail often
    Ryan Babineaux and John Krumboltz
    Embrace failure as a path to success. Take action, learn from mistakes, and unlock your potential for achievement.
    12 min
    / B Testing book cover
    / B Testing
    Dan Siroker and Pete Koomen
    Transform clicks into customers with data-driven A/B testing strategies.
    9 min