Connect to a RESTful service which ends all URLs with an "/"

46 Views Asked by At

I have to connect to a RESTful service that ends every URL with an "/".

The list of products is at

http://company.com/api/products/

And the product with the ID 1 is at

http://company.com/api/products/1/

This is my current app/adapters/products.js

import DS from 'ember-data';

export default DS.RESTAdapter.extend({
  host: 'http://company.com',
  namespace: 'api'
});

Is there a way to configure it so that it always ends a "/" at the end?

1

There are 1 best solutions below

0
Marcio Junior On BEST ANSWER

Overriding the buildURL method from DS.RESTAdapter and appending a slash should do the trick:

App.ApplicationAdapter= DS.RESTAdapter.extend({
  buildURL: function() {
    var url = this._super.apply(this, arguments);
    return url + '/';
  }
});