I was wondering if there's any way to display data from outside salesforce in a Lightning Web Component. I tried putting a fetch
call in the .js file of the component but it was blocked. Alternatively, would it work to make a JavaScript/React app that calls external data and nest it in a lightning web component?
My best guess as to why your call was blocked is that you did not whitelist the site you were trying to access.
This page describes how to perform callouts using fetch.
Alternatively, you can do the call out in the apex controller and return the results to the LWC.
Disclaimer
Due to the length of the article, I am not attempting to replicate it here.
make a JavaScript/React app that calls external data and nest it in a lightning web component
is not recommended, ideally, you would want to use lwc and slds and leverage SF's api's. as gNerb mentioned, you can easily fetch external content and display it in lwc. – glls Jul 4 at 1:38