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;
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
add a comment |
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
add a comment |
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
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
apex javascript lightning-web-components lwc-wire-adapter
edited Aug 3 at 21:22
boogie man
asked Aug 3 at 19:54
boogie manboogie man
304 bronze badges
304 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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>
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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>
add a comment |
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>
add a comment |
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>
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>
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
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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