Search code examples
ecmascript-6es6-promise

ES6 unexpected token


I'm trying to use es6 to keep this code a little cleaner however my code creates a fatal error unexpected token. What am I doing wrong here?

Example: Works - old javascript

('/admin/candidate_profile/edit/contact_details/' + this.props.candidateUserId)

Example: Doesn't work - es6

{`/admin/candidate_profile/edit/contact_details/${this.props.candidateUserId}`}

Solution

  • If you are trying to set a variable equal to the above statement then you don't need the curly braces. For example, the below snippet should work:

    let foo = `/admin/candidate_profile/edit/contact_details/${this.props.candidateUserId}`;