Atlassian Forge developers often encounter hurdles when handling asynchronous API calls, resulting in unexpected promise outputs that disrupt app functionality. This briefing explains how async functions return promises and how using hooks like useState helps dynamically manage UI state as data arrives.

  • Async functions return promises that represent future data.
  • The await keyword suspends execution until promise resolves.
  • useState hook manages asynchronous data and triggers UI updates.

What happened

Developers building their first Atlassian Forge apps often encounter issues when making API calls using async functions. Instead of immediately receiving data, these async methods return promises, which represent values not yet available. This causes errors or unexpected outputs like [object Promise] to appear in apps.

This challenge arises from the asynchronous nature of these functions and the need for explicit handling of promises. Unlike traditional synchronous functions that return concrete values, async functions return a promise object as a placeholder. Understanding how to properly await these promises is critical for accessing the actual data returned from API calls.

Why it matters

Without correctly handling async functions, developers face bugs and broken UI behavior that can halt app progress. Async/await syntax, introduced to improve readability over callbacks, allows asynchronous code to be written in a style that looks synchronous, improving maintainability and error handling.

In Forge, managing asynchronous data also requires interaction with UI lifecycle hooks such as useState. This hook tracks the state of data variables and triggers app re-renders when promise results arrive, ensuring that the app updates dynamically instead of showing unresolved promise objects. This leads to smoother user experiences and more robust apps.

What to watch next

Developers should deepen their knowledge of JavaScript async/await patterns and experiment with Forge UI Kit hooks beyond useState to fully leverage Forge’s reactive UI framework. Upcoming tutorials and blogs are expected to cover additional hooks and more complex asynchronous patterns.

Staying current with Atlassian’s developer resources will help Forge app builders better integrate asynchronous APIs, manage state effectively, and improve overall app responsiveness. Monitoring updates on Forge UI hooks and async best practices will be essential to mastering Forge app development.

Source assisted: This briefing began from a discovered source item from Atlassian Blog. Open the original source.
How SignalDesk reports: feeds and outside sources are used for discovery. Public briefings are edited to add context, buyer relevance and attribution before they are published. Read the standards

Related briefings