Closed reybango closed 8 years ago
context: '' should work. it is a prefix added to the path in that version so path can not end with '/'
@imrefazekas thanks again for taking the time to look into this. This is a very popular intro book to Node.js & Express development and I'm sure you're happy to see your awesome work referenced. :)
I know you did a PR in @EthanRBrown's repo but you may want to explain why the context should be set to '' and not '/'. If you look at the code from his book, he does create the context with a slash
Not sure if that's an artifact of an older version of connect-rest
when he originally wrote the book. I'll comment on that in the PR you made.
Contact is a prefix like I wrote above. The final path will be a concatenation of context and path, so a context of '/' and a path of '/api' would result a '//api' string at the end leading to a wrong result. So if you have no context, set it as an empty string.
@imrefazekas yep totally get that. I guess what I'm questioning is why the book example would set the context to a "/" and not an empty string. Since the book referenced deprecated code (e.g.: rest.rester()
), I was wondering if pre v2.0 code required the context to be "/".
The book was using version 0.9.X something, that context thing changed in version 1.0 for sure. For '/' you should have 0.9.X I believe, however, that version was not 1.0, so much reduced as for features and won't have promises for sure ...
@imrefazekas got it. I had a feeling that was the case. Appreciate the feedback.
Hi guys,
I'm working through a demo site and I was defining the API url as api.meadowlark:3000. So hitting an endpoint might look like http://api.meadowlark:3000/attractions
I defined the context as:
context: '/'
but doing so forced me to have to use an extra slash in the url like this:
http://api.meadowlark:3000//attractions
Defining the context as:
context: ''
fixed the issue so I didn't have to use an extra slash. I'm not sure if it's a bug or if it's expected behavior. The code can be referenced here:
https://github.com/reybango/meadowlark/blob/master/meadowlark.js#L178