-
Notifications
You must be signed in to change notification settings - Fork 27
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
How to implement custom routes? #434
Comments
Hey @jedfoster, I didn‘t try out the custom routes. But now I‘m interested to see why it doesn‘t work. PRs are always welcome. there‘s room for improvements. 👍 |
Hey @jedfoster, I tested it - your missing the apiRoutePath in this case /api in this mapping
|
Sure enough. I thought I had tried every possible permutation, but apparently I missed one. Changed my rewrite rule to: server.use(
jsonServer.rewriter({
'/blog/:resource/:id/show': '/api/:resource/:id',
'/articles?id=:id': '/api/posts/:id'
})
); And now http://localhost:3000/dev/blog/posts/1/show works perfectly. |
I didn't want to open a new issue, since I expect I'm missing something, but I can't get the rewriter example to work. I also am trying to figure out how exactly to customize the response object as described in this custom output/response example - any chance there's an example of that for json-serverless around? I tried a few variations on including
Anything obvious stand out to you? Thanks for json-serverless. I'm excited to use it. |
Hey @scafmac, I don‘t have a direct answer to that. I will check it tomorrow. br, |
@scafmac but I couldn`t even use this rewriter locally
need to test tomorrow if it works with json-server itself.... br, |
@scafmac sorry but I haven`t found the issue. br, |
I will close this issue now as I did not receive a further reply. |
I'm trying to figure out how to implement custom routes using json-server's rewriter.
I have tried this:
But I get
404 Not Found
from http://localhost:3000/dev/api/blog/posts/1/show (I'm using the example JSON from the json-server readme) http://localhost:3000/dev/api/posts/1 works just fine.What am I doing wrong?
On a related note, it would be nice if the
api/
path could be configured from appconfig.json. I may put in a PR for that change.The text was updated successfully, but these errors were encountered: