I am trying to retreive the text in LWC from a text file which I uploaded on static resource.

    import textfromStatic from '@salesforce/resourceUrl/Level_1';

    textfromStatic = textfromStatic;

Template looks like below :-

                    <p>text from static resource<lightning-formatted-text name="Typethis" value={textfromStatic}></lightning-formatted-text></p>


Output am receiving is below:-

static resource/resource/1610618314000/AnkushTest__Level_1
  • what is the content type of your static resource Mar 17, 2021 at 16:44

1 Answer 1


That's expected. Importing a static resource just imports a URL you can use to get the data. You need to still actually load the data somehow. At a very basic level, something like this should work:

this.staticResourceText = await fetch(textfromStatic, { credentials: 'include' });

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .