Skip to main content

Fetch API

Explore practical guides and implementation patterns for this topic.

Posts

Topic LWC
Lightning Web Components

How to Build a Real-Time Weather App in LWC Using External APIs

Connecting Salesforce Lightning Web Components (LWC) with external web services allows you to pull live third-party data directly into your user interface. In this step-by-step tutorial, we will build a dynamic weather component in LWC that fetches live weather forecasts based on user-entered locations using JavaScript's native fetch() API. In plain words: An LWC Weather Component takes a city or location name from an input box, sends an HTTP request to an external weather REST API, and presents live metrics like temperature and sky conditions right on the page.
Read article
Topic LWC
Lightning Web Components

How to Call External APIs in Salesforce LWC: Fetch vs. Apex Callouts Guide

In plain words: External API integration in Lightning Web Components (LWC) allows Salesforce components to send requests to third-party web services—such as toll calculation, mapping, or payment gateways. In Salesforce, you can invoke external endpoints either directly from JavaScript using the browser's fetch() API (with CSP Trusted Sites enabled) or securely through an Apex callout using Named Credentials . Connecting Salesforce applications with external web services is a core requirement in logistics, fleet management, and finance. For instance, querying a toll calculation service allows transportation teams to estimate route costs dynamically from an Account or Work Order page. Below, we break down how to configure network permissions and execute external API requests cleanly from an LWC component.
Read article
Topic LWC
Lightning Web Components

How to Make External HTTP Callouts from Salesforce LWC

In plain words: When building modern web applications, you often need to talk to third-party services—like checking if a phone number is valid, looking up weather data, or processing payments via an external API. In Salesforce Lightning Web Components (LWC), because your code runs directly in the browser, you can use the standard JavaScript fetch() method to talk directly to external web services without needing to write backend Apex controller code! Traditionally in Salesforce, if you needed to make an HTTP request to an external server, you had to route the call through an Apex class using the Http and HttpRequest classes. While Apex callouts are still mandatory for secure server-to-server communications, Lightning Web Components run on modern browsers that natively support the standard JavaScript fetch() API. In this guide, we will walk through how to build a phone number verification component that queries an external REST API directly from your LWC contro...
Read article
Topic Async Await Fetch API Frontend Architecture HTTP Requests Javascript REST API Web Development
Async Await Fetch API Frontend Architecture HTTP Requests Javascript REST API Web Development

How to Make HTTP Requests in JavaScript: Fetch API, Async/Await & Best Practices

In plain words: An HTTP request in JavaScript is a network message sent from a browser or application to a web server to retrieve data (GET), submit new records (POST), or modify resources (PUT/DELETE) asynchronously without reloading the entire webpage. Connecting to web services and third-party REST APIs is an essential building block of modern web development. Whether you are consuming public datasets, sending form inputs, or building interactive web applications, JavaScript provides built-in tools like the Promise-based Fetch API and async/await syntax to manage network requests cleanly.
Read article