samedi 26 août 2017

How to use dot characters in Ember query params

I have an Ember v2.14 app in which I'm trying to query an external API. The API takes query params that have dots (".") in the keys, like this:

http://ift.tt/2vf3GGI

I've tried setting up the queryParams in my controller like this:

// app/controllers/records.js

import Ember from 'ember';

export default Ember.Controller.extend({
  queryParams: ['query.code', 'code.system'],
  query.code: null,
  code.system: null
})

The Ember build fails with "Unexpected token" at the first dot character in the line after my queryParams declaration.

I've tried using percent-encoding to replace the dots, and this works fine if I enter this in the browser:

http://ift.tt/2vf3GGI

But the Ember build again fails if I attempt the same percent-encoding of my query params in the controller.

// app/controllers/records.js

import Ember from 'ember';

export default Ember.Controller.extend({
  queryParams: ['query%2Ecode', 'code%2Esystem'],
  query%2Ecode: null,
  code%2Esystem: null
})

Is anyone aware of something I should be doing differently?




Aucun commentaire:

Enregistrer un commentaire