You need to sign in to do that
Don't have an account?

LWC1503: Parsing error: Unexpected token
Hi Team,
can you please help me on why we are getting the below error

19:12:51.998 ended SFDX: Deploy Source to Org
19:20:15.573 Starting SFDX: Deploy Source to Org
=== Deploy Errors
PROJECT PATH ERRORS
──────────── ──────────────────────────────────────────────────────
LWC1503: Parsing error: Unexpected token (7:11) (7:11)
19:20:18.812 ended SFDX: Deploy Source to Org
Thanks,
Vijay.
can you please help me on why we are getting the below error
19:12:51.998 ended SFDX: Deploy Source to Org
19:20:15.573 Starting SFDX: Deploy Source to Org
=== Deploy Errors
PROJECT PATH ERRORS
──────────── ──────────────────────────────────────────────────────
LWC1503: Parsing error: Unexpected token (7:11) (7:11)
19:20:18.812 ended SFDX: Deploy Source to Org
Thanks,
Vijay.
Here recordId and objectApiName is a variable and you are using it as a string value, also use semicolon after the consol.log statement.
If this answer is helpful for you then mark it as the best answer.
I tried but still i am getting the same error .
Js file :
import { LightningElement,api } from 'lwc';
export default class CurrentRecordAndObjectInfo extends LightningElement {
@api recordId;
@api objectApiName;
console.log('recordId');
console.log('objectApiName');
}
Thanks,
Vijay.
Js file :
import { LightningElement,api } from 'lwc';
export default class CurrentRecordAndObjectInfo extends LightningElement {
@api recordId;
@api objectApiName;
console.log('recordId'+recordID);
console.log('objectApiName'+objectApiName);
}
Thanks
Suraj Tripathi.
If this answer is helpful for you then mark it as the best answer.
i have tried the above code but still seeing the error parameter declartion expected .
I
Thanks,
Vijay.
the javascript is a case sensitive so you have to right the same name as you define at @api
you can check that code below,s
Js file :
Thanks
Suraj Tripathi.
I have changed the code but still seeing the error
.
{
"resource": "/c:/Users/91773/OneDrive/Desktop/SFDCFACTS/CounterVaraibleLog/force-app/main/default/lwc/currentRecordAndObjectInfo/currentRecordAndObjectInfo.js",
"owner": "typescript",
"code": "1138",
"severity": 8,
"message": "Parameter declaration expected.",
"source": "ts",
"startLineNumber": 5,
"startColumn": 27,
"endLineNumber": 5,
"endColumn": 28
}
Thanks,
Vijay
Hi Vijay,
You are getting this syntax error as you need to use any Lifecycle hook to call console/JS function,
More info on LWC Lifecycle Hooks: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/reference_lifecycle_hooks
Please try the below code:
Regards,
Raghu
Hi Vijay,
to access the variables, you need to use this keyword.
Please try the below code:
Regards,
Dragan