-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mock url #13
Comments
Good idea! |
I've been thinking about this. How would the tool know to do Is it because it's a number? Is it a guarantee that numbers are always id's? It might be confusing with special cases like that. So I think that either the last thing after a / is either a folder or the filename. I choose filename because if you want /6 and /7 it's easier to create and less folders. What do you think @stepan-romankov ? |
Sorry @seriema, seems to be misunderstanding. I mean it will be good to have http://mydomain.com/mock_data/somting/get.json instead of http://mydomain.com/mock_data/somting.get.json so the list of something will be in the same deirectory with item of something. So if what I say makes sense that final / should not be cleaned up during URL replacement. if (newPath[newPath.length - 1] === '/') {
newPath = newPath.slice(0, -1);
} or at least it can be optional |
Also what about replacing HTTP METHOD for all requests with GET? It will allow to mock POST requests |
Exactly, I was just pointing out an inconsistency in your samples. So And See what I mean? It's hard for the code to know if the last part of the URL should be included in the name or not. |
Is it not working with POST requests? If so, could you open a new issue and explain a bit more? Thanks! |
Finally how I see it should be: So it should take into account last "/" but not cut it all the time. In this case list resources can have / at the end of url and items will not have such. Does it makes sense? |
I see! I wonder if most developers aren't a bit sloppy with ending '/'? I know I am. Not being consistent with that would make the interceptor go try different paths which would confuse the developer. I could agree on either or. Either it always does as currently, or it always turns the last parameter into a folder. This would be easy and could be configured in the Is that an OK compromise? Or that wouldn't really help at all? |
Thanks for your reply! |
Glad to have your feedback :) Just so I'm sure, "stripTrailingSlash" would be my compromise to your suggestion then? I'll probably call it something else as what it's actually doing is always use folders. |
Agree with you! |
Awesome! I'll add this to my todo-list. ^^ |
Is it it possible to add an option to configure url for mock data requests.
Lets say that we have following real REST urls :
"http://mydomain.com/api/somting" - a list of something
"http://mydomain.com/api/somting/5" - an item
then mocked path's for them will be :
"http://mydomain.com/mock_data/somting.get.json"
"http://mydomain.com/mock_data/somting/5.get.json"
From my point of view it will be more clean to have all mock data for an entity in the same directory:
"http://mydomain.com/mock_data/somting/get.json" - a mocked list of something
"http://mydomain.com/mock_data/somting/5.get.json" - - a mocked item
Would be very appreciate you if you add such option.
The text was updated successfully, but these errors were encountered: