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

Accurately recalling the key - can everyone do it?

Can birds evolve without trees?

What do the screens say after you are set free?

A wiild aanimal, a cardinal direction, or a place by the water

Why have both: BJT and FET transistors on IC output?

Is verification of a blockchain computationally cheaper than recreating it?

Protect a 6 inch air hose from physical damage

"Will flex for food". What does this phrase mean?

speaker impedence

What's the proper way of indicating that a car has reached its destination during a dialogue?

How is Sword Coast North governed?

Python π = 1 + (1/2) + (1/3) + (1/4) - (1/5) + (1/6) + (1/7) + (1/8) + (1/9) - (1/10) ...1748 Euler

Can I say "Gesundheit" if someone is coughing?

Adding a (stair/baby) gate without facing walls

Heinlein story regarding suspended animation and reading newspapers?

UX writing: When to use "we"?

How were x-ray diffraction patterns deciphered before computers?

What sort of solar system / atmospheric conditions, if any, would allow for a very cold planet that still receives plenty of light from its sun?

What is the difference between 2/4 and 4/4 when it comes the accented beats?

How did Biff return to 2015 from 1955 without a lightning strike?

How does Rust's 128-bit integer `i128` work on a 64-bit system?

How to get maximum number that newcount can hold?

When did J.K. Rowling decide to make Ron and Hermione a couple?

What is Albrecht Dürer's Perspective Machine drawing style?



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;








2















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
































    2















    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




























      2












      2








      2








      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 7 hours ago







      boogie man

















      asked 8 hours ago









      boogie manboogie man

      254 bronze badges




      254 bronze badges























          1 Answer
          1






          active

          oldest

          votes


















          2














          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




















          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            7 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            7 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            7 hours ago













          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









          2














          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




















          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            7 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            7 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            7 hours ago















          2














          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




















          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            7 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            7 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            7 hours ago













          2












          2








          2







          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 8 hours ago









          Mohith ShrivastavaMohith Shrivastava

          63.5k7 gold badges109 silver badges155 bronze badges




          63.5k7 gold badges109 silver badges155 bronze badges










          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            7 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            7 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            7 hours ago












          • 1





            Please update your question with latest code in your org

            – Mohith Shrivastava
            7 hours ago






          • 1





            Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

            – Mohith Shrivastava
            7 hours ago






          • 1





            Check my front end code .I have changed that as well .You should use right properties

            – Mohith Shrivastava
            7 hours ago






          • 1





            I was able to get it working in my org fine

            – Mohith Shrivastava
            7 hours ago






          • 1





            On the front end you have postInfo.data , it should be postInfo.

            – Mohith Shrivastava
            7 hours ago







          1




          1





          Please update your question with latest code in your org

          – Mohith Shrivastava
          7 hours ago





          Please update your question with latest code in your org

          – Mohith Shrivastava
          7 hours ago




          1




          1





          Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

          – Mohith Shrivastava
          7 hours ago





          Also note I changed variable names as well in my answer .You had same variables for your wire and track properties which could also be tht cause of the issue

          – Mohith Shrivastava
          7 hours ago




          1




          1





          Check my front end code .I have changed that as well .You should use right properties

          – Mohith Shrivastava
          7 hours ago





          Check my front end code .I have changed that as well .You should use right properties

          – Mohith Shrivastava
          7 hours ago




          1




          1





          I was able to get it working in my org fine

          – Mohith Shrivastava
          7 hours ago





          I was able to get it working in my org fine

          – Mohith Shrivastava
          7 hours ago




          1




          1





          On the front end you have postInfo.data , it should be postInfo.

          – Mohith Shrivastava
          7 hours ago





          On the front end you have postInfo.data , it should be postInfo.

          – Mohith Shrivastava
          7 hours ago

















          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

          ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

          Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

          19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу