Connect to a RESTful service that ends all urls "/"

I need to connect to a RESTful service that ends each url with "/".

Product list is in

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

      

And the product with ID 1 is on

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 set it up so that it always ends with a "/"?

+3


source to share


1 answer


Overriding the method buildURL

from DS.RESTAdapter

and adding a forward slash should do the trick:



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

      

+5


source







All Articles