Search code examples
ruby-on-rails-4vue.jsexecjsvue-resource

ExecJS Unexpected token: operator (>) in vue.js method


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.


Solution

  • 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')
        })
      },