BBC News LWC
2022 / Salesforce Project
1. Develop a Lightning Web Component that displays the top ten news articles from BBC News.
2. Create a lighting tab and display this component in this tab.
To bring news articles from the BBC News website to our lightning web component, we have to use the BBC News API. I looked to see if the official BBC API was available, but I couldn’t find any. In my search for an API to meet this requirement, I came across the fantastic NewsAPI.org API, and this API service was a perfect fit.
There are two ways of making a callout from the lightning web component.
- Using Apex code
HTTP Callout architecture
To authenticate the NewsAPI, I used the Salesforce Named Credentials platform feature. NewsAPI API keys can be obtained by registering on their website.
Here’s how I made a call to news API from the Apex code.
Quick News Lightning Component
News App | It displays the latest news articles from different news sources.