danwrong / restler

REST client library for node.js
MIT License
1.99k stars 391 forks source link

Does not support api url prefix ? #210

Open JuoCode opened 9 years ago

JuoCode commented 9 years ago

My api url like this

http://domain.com/api/xxxxx

But i set baseURL: http://domain.com/api/xxxxx not work :(

It seem to be the /api prefix is ignored,can support this ?

JuoCode commented 9 years ago

I see it, use url.resolve so the /api is processed out, can you add a new configuration item prefix?

tbloncar commented 9 years ago

In case others run into this: It seems that a trailing slash on the baseURL and no preceding slash on your path argument will play nicely with url.resolve. This worked for me:

API = restler.service(function() {}, {
  baseURL: '/api/v1/'
}, {
  createWidget: function(widget) {
    return this.post('widgets', { widget: widget });
  }
});