function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sen19sen19 

how to resolve undefined assignment in helper.js

I have a apex class which is having one method with returntype wrapper class. i am binding the return type in helper in a response attribute (type is object). I want to fetch two variables i.e. id,status from response. Currently I am getting undefined error in output.
Reponse attribute in cmp:
<aura:attribute name="response" type="object"/>
Helper.js:
({ getStatusHelper : function(component, event,helper) {
var jobID = event.getParam("Pass_Result");
component.set("v.jobId", jobID); var action = component.get("c.getCalloutResponseStatus"); action.setParams({"jobId": jobID});
action.setCallback(this, function(response) { var state = response.getState();
if (component.isValid() && state === "SUCCESS") { component.set("v.response", response.getReturnValue());
**var getStatus = component.get("v.response").status; //GETTING UNDEFINED ERROR
var getJobId = component.get("v.response").id; //GETTING UNDEFINED ERROR**
}
else{ alert('Failed status call from child!!'); } }); $A.enqueueAction(action); }
})
can anyone pls help me on this issue
Best Answer chosen by sen19
Agustin BAgustin B
Hi Ananga, try this:
var wrap = response.getReturnValue();
component.set("v.response", wrap);
var getStatus = wrap.status; 
var getJobId = wrap.id;

You can also validate if you are getting the information properly using console.log(response.getReturnValue());
If it helps please like and mark the comment as correct so the question is closed and it can help others with similar issues.

All Answers

sandeep zlatosandeep zlato

I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. For Some Useful Printer Related Information anyone can visit us.
 
Agustin BAgustin B
Hi Ananga, try this:
var wrap = response.getReturnValue();
component.set("v.response", wrap);
var getStatus = wrap.status; 
var getJobId = wrap.id;

You can also validate if you are getting the information properly using console.log(response.getReturnValue());
If it helps please like and mark the comment as correct so the question is closed and it can help others with similar issues.
This was selected as the best answer