LWC component not renderingFIELD_INTEGRITY_EXCEPTION Invalid attributGetting data from Lightning componentHow to use JsForce in a Salesforce Lightning ComponentIs there a way to load every label data and every SObject description data in Lightning Web Component using only Javascript without any Apex?LWC : passing parameter to getrecordlwc data-table not renderingDoes LWC @wire works with custom classes?A @track decorator can only be applied to a public fieldRenaming LWC const variable breaks component behaviorApex method not getting invoked in LWC

Unconventional examples of mathematical modelling

Word for an event that will likely never happen again

Doesn't the speed of light limit imply the same electron can be annihilated twice?

Are there liquid fueled rocket boosters having coaxial fuel/oxidizer tanks?

What unique challenges/limitations will I face if I start a career as a pilot at 45 years old?

How would armour (and combat) change if the fighter didn't need to actually wear it?

Telephone number in spoken words

Lípínguapua dopo Pêpê

How do I call a 6-digit Australian phone number with a US-based mobile phone?

Output the list of musical notes

Suspension compromise for urban use

Is there a word for returning to unpreparedness?

What can I do to increase the amount of LEDs I can power with a pro micro?

What would cause a nuclear power plant to break down after 2000 years, but not sooner?

"Mouth-breathing" as slang for stupidity

Why aren't rainbows blurred-out into nothing after they are produced?

Is there any official ruling on how characters go from 0th to 1st level in a class?

How can I find an old paper when the usual methods fail?

When was "Fredo" an insult to Italian-Americans?

What should we do with manuals from the 80s?

Match 4 columns and replace 1 in 2 files

Why won't the Republicans use a superdelegate system like the DNC in their nomination process?

How to prevent criminal gangs from making/buying guns?

Stop email from sending using AMPscript



LWC component not rendering


FIELD_INTEGRITY_EXCEPTION Invalid attributGetting data from Lightning componentHow to use JsForce in a Salesforce Lightning ComponentIs there a way to load every label data and every SObject description data in Lightning Web Component using only Javascript without any Apex?LWC : passing parameter to getrecordlwc data-table not renderingDoes LWC @wire works with custom classes?A @track decorator can only be applied to a public fieldRenaming LWC const variable breaks component behaviorApex method not getting invoked in LWC






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I have a lightning web component that wires an apex method that calls out to JSONplaceholder.com to get back some data. I'm having issue with the whole component rendering at all. While in community builder (component lives in a community) I occasionally get an error saying



"This page has an error. You might just need to refresh it. Failed to initialize a component [postId is not defined] Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: siteforce-generatedpage-143e6e1e-5839-4709-8899-f2536a9ff760.c1564858326133".



I've confirmed the apex works by running it in the dev console.



Here is the code:



Apex



public without sharing class postController 

@AuraEnabled(cacheable=true)
public static String getPosts(Integer postId)
Http http = new Http();
HttpRequest req = new HttpRequest();

string resource = 'https://jsonplaceholder.typicode.com/comments?postId=' + postId;

req.setEndpoint(resource);
req.setMethod('GET');

HttpResponse res = http.send(req);
String jsonData = res.getBody();
system.debug(jsonData);
return jsonData;




JS



import LightningElement, track, wire from 'lwc';
import getPosts from '@salesforce/apex/postController.getPosts';

export default class PracticePosts extends LightningElement

@track postInfo = [];
@track postId = 1;
@track error;

@wire(getPosts, postId: `$postId`)
getJSON(error, data)
if (data)
this.postInfo = JSON.parse(data);
else if (error)
this.error = error;





HTML



<template>
<lightning-card title="Posts" icon-name="custom:custom67">
<div class="slds-m-horizontal-medium">
<template if:true=postInfo.data>
<p>My dataaaaaaa</p>
<ul>
<li for:each=postInfo.data for:item="post" key=post.id>post.name</li>
</ul>
</template>
<template if:true=postInfo.error>
<p>Dang</p>
<p>postInfo.error</p>
</template>
</div>
</lightning-card>
</template>









share|improve this question
































    3















    I have a lightning web component that wires an apex method that calls out to JSONplaceholder.com to get back some data. I'm having issue with the whole component rendering at all. While in community builder (component lives in a community) I occasionally get an error saying



    "This page has an error. You might just need to refresh it. Failed to initialize a component [postId is not defined] Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: siteforce-generatedpage-143e6e1e-5839-4709-8899-f2536a9ff760.c1564858326133".



    I've confirmed the apex works by running it in the dev console.



    Here is the code:



    Apex



    public without sharing class postController 

    @AuraEnabled(cacheable=true)
    public static String getPosts(Integer postId)
    Http http = new Http();
    HttpRequest req = new HttpRequest();

    string resource = 'https://jsonplaceholder.typicode.com/comments?postId=' + postId;

    req.setEndpoint(resource);
    req.setMethod('GET');

    HttpResponse res = http.send(req);
    String jsonData = res.getBody();
    system.debug(jsonData);
    return jsonData;




    JS



    import LightningElement, track, wire from 'lwc';
    import getPosts from '@salesforce/apex/postController.getPosts';

    export default class PracticePosts extends LightningElement

    @track postInfo = [];
    @track postId = 1;
    @track error;

    @wire(getPosts, postId: `$postId`)
    getJSON(error, data)
    if (data)
    this.postInfo = JSON.parse(data);
    else if (error)
    this.error = error;





    HTML



    <template>
    <lightning-card title="Posts" icon-name="custom:custom67">
    <div class="slds-m-horizontal-medium">
    <template if:true=postInfo.data>
    <p>My dataaaaaaa</p>
    <ul>
    <li for:each=postInfo.data for:item="post" key=post.id>post.name</li>
    </ul>
    </template>
    <template if:true=postInfo.error>
    <p>Dang</p>
    <p>postInfo.error</p>
    </template>
    </div>
    </lightning-card>
    </template>









    share|improve this question




























      3












      3








      3








      I have a lightning web component that wires an apex method that calls out to JSONplaceholder.com to get back some data. I'm having issue with the whole component rendering at all. While in community builder (component lives in a community) I occasionally get an error saying



      "This page has an error. You might just need to refresh it. Failed to initialize a component [postId is not defined] Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: siteforce-generatedpage-143e6e1e-5839-4709-8899-f2536a9ff760.c1564858326133".



      I've confirmed the apex works by running it in the dev console.



      Here is the code:



      Apex



      public without sharing class postController 

      @AuraEnabled(cacheable=true)
      public static String getPosts(Integer postId)
      Http http = new Http();
      HttpRequest req = new HttpRequest();

      string resource = 'https://jsonplaceholder.typicode.com/comments?postId=' + postId;

      req.setEndpoint(resource);
      req.setMethod('GET');

      HttpResponse res = http.send(req);
      String jsonData = res.getBody();
      system.debug(jsonData);
      return jsonData;




      JS



      import LightningElement, track, wire from 'lwc';
      import getPosts from '@salesforce/apex/postController.getPosts';

      export default class PracticePosts extends LightningElement

      @track postInfo = [];
      @track postId = 1;
      @track error;

      @wire(getPosts, postId: `$postId`)
      getJSON(error, data)
      if (data)
      this.postInfo = JSON.parse(data);
      else if (error)
      this.error = error;





      HTML



      <template>
      <lightning-card title="Posts" icon-name="custom:custom67">
      <div class="slds-m-horizontal-medium">
      <template if:true=postInfo.data>
      <p>My dataaaaaaa</p>
      <ul>
      <li for:each=postInfo.data for:item="post" key=post.id>post.name</li>
      </ul>
      </template>
      <template if:true=postInfo.error>
      <p>Dang</p>
      <p>postInfo.error</p>
      </template>
      </div>
      </lightning-card>
      </template>









      share|improve this question
















      I have a lightning web component that wires an apex method that calls out to JSONplaceholder.com to get back some data. I'm having issue with the whole component rendering at all. While in community builder (component lives in a community) I occasionally get an error saying



      "This page has an error. You might just need to refresh it. Failed to initialize a component [postId is not defined] Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: siteforce-generatedpage-143e6e1e-5839-4709-8899-f2536a9ff760.c1564858326133".



      I've confirmed the apex works by running it in the dev console.



      Here is the code:



      Apex



      public without sharing class postController 

      @AuraEnabled(cacheable=true)
      public static String getPosts(Integer postId)
      Http http = new Http();
      HttpRequest req = new HttpRequest();

      string resource = 'https://jsonplaceholder.typicode.com/comments?postId=' + postId;

      req.setEndpoint(resource);
      req.setMethod('GET');

      HttpResponse res = http.send(req);
      String jsonData = res.getBody();
      system.debug(jsonData);
      return jsonData;




      JS



      import LightningElement, track, wire from 'lwc';
      import getPosts from '@salesforce/apex/postController.getPosts';

      export default class PracticePosts extends LightningElement

      @track postInfo = [];
      @track postId = 1;
      @track error;

      @wire(getPosts, postId: `$postId`)
      getJSON(error, data)
      if (data)
      this.postInfo = JSON.parse(data);
      else if (error)
      this.error = error;





      HTML



      <template>
      <lightning-card title="Posts" icon-name="custom:custom67">
      <div class="slds-m-horizontal-medium">
      <template if:true=postInfo.data>
      <p>My dataaaaaaa</p>
      <ul>
      <li for:each=postInfo.data for:item="post" key=post.id>post.name</li>
      </ul>
      </template>
      <template if:true=postInfo.error>
      <p>Dang</p>
      <p>postInfo.error</p>
      </template>
      </div>
      </lightning-card>
      </template>






      apex javascript lightning-web-components lwc-wire-adapter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 3 at 21:22







      boogie man

















      asked Aug 3 at 19:54









      boogie manboogie man

      304 bronze badges




      304 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          4














          There are some fundamental issues with the code.



          The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



          Here is how the correct JS code looks like



          import LightningElement, track, wire from 'lwc';
          import getPosts from '@salesforce/apex/postController.getPosts';


          export default class JsonTest extends LightningElement

          @track postInfo = [];
          @track postId = 1;
          @track error;

          @wire(getPosts, postId: '$postId')
          getJSON(error, data)
          if (data)
          this.postInfo = JSON.parse(data);
          else if (error)
          this.error = error;





          The HTML template file is as below



          <template>
          <lightning-card title="Posts" icon-name="custom:custom67">
          <div class="slds-m-horizontal-medium">
          <template if:true=postInfo>
          <p>My dataaaaaaa</p>
          <ul>
          <li for:each=postInfo for:item="post" key=post.id>post.name</li>
          </ul>
          </template>
          <template if:true=postInfo.error>
          <p>Dang</p>
          <p>postInfo.error</p>
          </template>
          </div>
          </lightning-card>
          </template>





          share|improve this answer



























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "459"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f272242%2flwc-component-not-rendering%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            There are some fundamental issues with the code.



            The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



            Here is how the correct JS code looks like



            import LightningElement, track, wire from 'lwc';
            import getPosts from '@salesforce/apex/postController.getPosts';


            export default class JsonTest extends LightningElement

            @track postInfo = [];
            @track postId = 1;
            @track error;

            @wire(getPosts, postId: '$postId')
            getJSON(error, data)
            if (data)
            this.postInfo = JSON.parse(data);
            else if (error)
            this.error = error;





            The HTML template file is as below



            <template>
            <lightning-card title="Posts" icon-name="custom:custom67">
            <div class="slds-m-horizontal-medium">
            <template if:true=postInfo>
            <p>My dataaaaaaa</p>
            <ul>
            <li for:each=postInfo for:item="post" key=post.id>post.name</li>
            </ul>
            </template>
            <template if:true=postInfo.error>
            <p>Dang</p>
            <p>postInfo.error</p>
            </template>
            </div>
            </lightning-card>
            </template>





            share|improve this answer





























              4














              There are some fundamental issues with the code.



              The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



              Here is how the correct JS code looks like



              import LightningElement, track, wire from 'lwc';
              import getPosts from '@salesforce/apex/postController.getPosts';


              export default class JsonTest extends LightningElement

              @track postInfo = [];
              @track postId = 1;
              @track error;

              @wire(getPosts, postId: '$postId')
              getJSON(error, data)
              if (data)
              this.postInfo = JSON.parse(data);
              else if (error)
              this.error = error;





              The HTML template file is as below



              <template>
              <lightning-card title="Posts" icon-name="custom:custom67">
              <div class="slds-m-horizontal-medium">
              <template if:true=postInfo>
              <p>My dataaaaaaa</p>
              <ul>
              <li for:each=postInfo for:item="post" key=post.id>post.name</li>
              </ul>
              </template>
              <template if:true=postInfo.error>
              <p>Dang</p>
              <p>postInfo.error</p>
              </template>
              </div>
              </lightning-card>
              </template>





              share|improve this answer



























                4












                4








                4







                There are some fundamental issues with the code.



                The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



                Here is how the correct JS code looks like



                import LightningElement, track, wire from 'lwc';
                import getPosts from '@salesforce/apex/postController.getPosts';


                export default class JsonTest extends LightningElement

                @track postInfo = [];
                @track postId = 1;
                @track error;

                @wire(getPosts, postId: '$postId')
                getJSON(error, data)
                if (data)
                this.postInfo = JSON.parse(data);
                else if (error)
                this.error = error;





                The HTML template file is as below



                <template>
                <lightning-card title="Posts" icon-name="custom:custom67">
                <div class="slds-m-horizontal-medium">
                <template if:true=postInfo>
                <p>My dataaaaaaa</p>
                <ul>
                <li for:each=postInfo for:item="post" key=post.id>post.name</li>
                </ul>
                </template>
                <template if:true=postInfo.error>
                <p>Dang</p>
                <p>postInfo.error</p>
                </template>
                </div>
                </lightning-card>
                </template>





                share|improve this answer













                There are some fundamental issues with the code.



                The return type is a string as per your backend apex class and hence first thing is to parse the response into Javascript object .In your case the API is returning an Array and hence you will need an Array variable .



                Here is how the correct JS code looks like



                import LightningElement, track, wire from 'lwc';
                import getPosts from '@salesforce/apex/postController.getPosts';


                export default class JsonTest extends LightningElement

                @track postInfo = [];
                @track postId = 1;
                @track error;

                @wire(getPosts, postId: '$postId')
                getJSON(error, data)
                if (data)
                this.postInfo = JSON.parse(data);
                else if (error)
                this.error = error;





                The HTML template file is as below



                <template>
                <lightning-card title="Posts" icon-name="custom:custom67">
                <div class="slds-m-horizontal-medium">
                <template if:true=postInfo>
                <p>My dataaaaaaa</p>
                <ul>
                <li for:each=postInfo for:item="post" key=post.id>post.name</li>
                </ul>
                </template>
                <template if:true=postInfo.error>
                <p>Dang</p>
                <p>postInfo.error</p>
                </template>
                </div>
                </lightning-card>
                </template>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 3 at 20:32









                Mohith ShrivastavaMohith Shrivastava

                63.8k7 gold badges109 silver badges155 bronze badges




                63.8k7 gold badges109 silver badges155 bronze badges






























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Salesforce Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f272242%2flwc-component-not-rendering%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

                    Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

                    Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림