I have the following code on Apex side
public without sharing class GetClaimnsIntake {
@AuraEnabled
public static String isPolicyValid(String policyNum, string effectiveDate){
try {
String url = 'callout:Get_Claims_Intake?policyNumber='+policyNum+'&effectiveDate='+effectiveDate;
system.debug(url);
String apiKey = System.Label.apiKey;
String responseReturned = 'false';
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setHeader('Ocp-Apim-Subscription-Key', apiKey);
req.setHeader('Accept', 'application/json');
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(url);
req.setMethod('GET');
HttpResponse res = h.send(req);
if(res.getStatusCode() == 200){
Map<String, String> values = (Map<String, String>) JSON.deserialize(res.getBody(), Map<String, String>.class);
system.debug(values);
String theKey = values.get(System.Label.ClaimKey);
if(theKey == System.Label.ClaimKeyValue) {
responseReturned = values.get('Value');
system.debug('responseReturned'+ responseReturned);
}
}
return responseReturned;
} catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
}
}
I am having user enter a date and policy number from UI and in js i am passing the values to apex
handleFormSubmit() {
if(this.validateForm()){
this.showModal= true;
}
else {
this.showMessageToUser('error', 'dismissible', 'Please provide data in fields marked as required.');
}
}
handleValueChange(event) {
if(event.target.name == 'PolicyNumberId'){
this.policyNum = event.target.value;
}
if(event.target.name == 'Policy Effective date'){
this.effectiveDate = date.parse(event.target.value);
}
}
submitDetails() {
this.isProcessing = true;
console.log( this.policyNum);
console.log(this.effectiveDate);
isPolicyValid({ policyNum:this.policyNum, effectiveDate:this.effectiveDate })
.then((result) => {
console.log('**',result);
this.isValid = result;
console.log(this.isValid )
this.error = undefined;
this.closeModal();
})
.catch((error) => {
this.error = error;
this.contacts = undefined;
});
}
handleClick() {
this.template.querySelectorAll('lightning-input[data-id="input"]').forEach(element => {
element.value = null;
});
}
}
How can i convert the date so that I can pas sit as '6/5/21' into apex as string. I am capturing it as