Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I am having this method in my vue object:

  fetchStates: function () {
    this.$http.get('/api/locations/all_states').then((response) => {
      states = $.parseJSON(response.responseText).states
      this.$set('states', states)
    }).then(() => {
      $('.cs-select').trigger('chosen:updated')
    })
  },

during assets precompiling I get this error:

ExecJS::ProgramError: Unexpected token: operator (>) (line: 62960, col: 69, pos: 1897152)

I managed to locate where this comes from, .then((response) => {, but no idea how to fix this. May be ExecJS doesn't know about promises syntax in vue-resource. Any help is appreciated.

share|improve this question
up vote 2 down vote accepted

Well, for those who'll have the same issue, this is were my problem was, it should be .then(function(response) { instead of .then((response) => {

  fetchStates: function () {
    this.$http.get('/api/locations/all_states').then(function(response) {
      states = $.parseJSON(response.responseText).states
      paymentInfo.$set('states', states)
    }).then(function() {
      $('.cs-select').trigger('chosen:updated')
    })
  },
share|improve this answer
    
This is interesting, i've had a similar issue, where the same code with the '=>' syntax worked in desktop and android, but didn't work in iOS. So i debugged it on iOS and i got the same exception like yours - "Unexpected token: operator (>)". I'm not sure about it, but i think the '=>' is a js6 standard and maybe it's still not fully supported. If you know more information about this i'd love to hear. In the mean time, your solution worked for me as well +1. – Itai Spector Aug 17 at 16:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.