function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonathan Crow 6Jonathan Crow 6 

Lightning Web Component to fetch api

I am trying to fetch data from an API. I took a look at this recipe from the LWC Recipes: https://github.com/trailheadapps/lwc-recipes/tree/main/force-app/main/default/lwc/miscRestApiCall

But I need to authenticate the call to the API with my API Key and have no idea how to do that.

Can anyone point me to any resources for doing this in LWC?
ANUTEJANUTEJ (Salesforce Developers) 
Hi Jonathan,

>> https://developer.salesforce.com/blogs/2020/04/how-to-securely-access-salesforce-with-lightning-web-components-open-source.html

This link has details in regards to authentication on the server-side and also client-side authentication.

Additionally, you can try checking this link as well : https://blog.salesforcecasts.com/using-fetch-api-in-lwc/

Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.  

Thanks.