angular / in-memory-web-api

The code for this project has moved to the angular/angular repo. This repo is now archived.
MIT License
1.18k stars 230 forks source link

Cannot handle multilevel URI's #233

Open lefebvresam opened 5 years ago

lefebvresam commented 5 years ago

I would like to handle requests such as:

get("api/buildings") and get("api/buildings/details?id=1")

But this seems not to be working.

I'm restricted to: get("api/buildings") and get("api/buildingdetails/1")

The info in the help is very limited on that.

cogitaria-admin commented 5 years ago

Multiple segments is clearly a fundamental requirement but in the author's defense he stipulates this is only a toy library and "not for production". He also notes he will break at-will versus using semantic versioning? Not sure why that's the case. Anyway, he's at least honest about limitations. It's a nice little tool for what it was intended for.

You can actually change the property names to strings, but you'll get "unknown ID fruits" or an error to that effect if you add a key "/produce/fruits/citrus" for example.

produce/ produce/fruits produce/fruits/citrus

It's unfortunate because it's relatively close to being more generally useful. I think I will start from scratch and add a simple key-value lookup where key is URL and value is JSON response. So essentially you add an interceptor (easy and baked into Angular HTTP) that does a look-up of the URL on a dictionary. Something like that.