kitloong / json-server-vercel Goto Github PK
View Code? Open in Web Editor NEWDeploy JSON Server to Vercel
Home Page: https://json-server-in.vercel.app
License: MIT License
Deploy JSON Server to Vercel
Home Page: https://json-server-in.vercel.app
License: MIT License
How can I modify database on api vercel?
hi , I used your template and I replaced my db.json file, but I can't to go the routes of my json file like what your example does
for you its working when I visit this URL https://json-server-in.vercel.app/api/posts
but for me its like below: https://json-serverati.netlify.app/api/categoryList
I appreciate your help.
is the updated data saved in the db.json
JSON file for life time like if I can't delete data? I found so many blogs that don't save data for life time . it's automatically deleted after some time. So, there is anyother way to do that?
Hello,
In module usage everything is working perfect, but /register - does not register new users, it says - you must add "users" (but "users" already exist). Paradox: at the same time /register knows that your email was registered, by checking it in "users" and it sends message : "email already exist".
*User registered earlier localy.
const jsonServer = require("json-server");
const auth = require("json-server-auth");
const server = jsonServer.create();
const router = jsonServer.router("db.json");
const middlewares = jsonServer.defaults();
server.db = router.db;
// Add this before server.use(router)
server.use(middlewares);
server.use(auth);
server.use(router);
server.listen(3000, () => {
console.log("JSON Server is running");
});
// Export the Server API
module.exports = server;
Try to make post request but fail:
Error: EROFS: read-only file system, open './db.json'
at Object.openSync (node:fs:601:3)
at writeFileSync (node:fs:2249:35)
at FileSync.write (/var/task/node_modules/.pnpm/[email protected]/node_modules/lowdb/adapters/FileSync.js:53:14)
at db.write (/var/task/node_modules/.pnpm/[email protected]/node_modules/lowdb/lib/main.js:37:21)
at /var/task/node_modules/.pnpm/[email protected]/node_modules/json-server/lib/server/router/write.js:5:8
at Layer.handle [as handle_request] (/var/task/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
at next (/var/task/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:144:13)
at create (/var/task/node_modules/.pnpm/[email protected]/node_modules/json-server/lib/server/router/plural.js:246:5)
at Layer.handle [as handle_request] (/var/task/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
at next (/var/task/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:144:13)
When i try to post some in my db.json, i'm getting a 500 error on http request. The post is did but the response in code get a error and the code stops working. If you test the endpoint in postman, you will receive the following warning:
Error: EROFS: read-only file system, open 'db.json'
at Object.openSync (node:fs:600:3)
at writeFileSync (node:fs:2221:35)
at FileSync.write (/var/task/node_modules/.pnpm/[email protected]/node_modules/lowdb/adapters/FileSync.js:53:14)
at db.write (/var/task/node_modules/.pnpm/[email protected]/node_modules/lowdb/lib/main.js:37:21)
at /var/task/node_modules/.pnpm/[email protected]/node_modules/json-server/lib/server/router/write.js:5:8
at Layer.handle [as handle_request] (/var/task/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
at next (/var/task/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:144:13)
at create (/var/task/node_modules/.pnpm/[email protected]/node_modules/json-server/lib/server/router/plural.js:246:5)
at Layer.handle [as handle_request] (/var/task/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/layer.js:95:5)
at next (/var/task/node_modules/.pnpm/[email protected]/node_modules/express/lib/router/route.js:144:13)
Can you help me, please?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.