-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
POST & DELETE request 500 #6
Comments
I fixed this by adding these three lines at the top of the file const fs = require("fs")
const path = require("path")
const db = JSON.parse(fs.readFileSync(path.join("db.json"))) Then you can update router to use the
|
Thank you, your code is working well. |
@nicopcat , @VicAv99 thanks for covering this issues on regarding server deployment. My another question, is that you guys have an experience using |
Thanks @VicAv99 , I have added your solution to the |
this is so nice - appreciate everyone. |
I am confused! Are you guys implementing this for persisting data till the serverless function dies? The data will just get deleted after the serverless function stops. If it works like that why is it disabled/commented out? Even in the demo app, you can enable POST/DELETE without any consequence because data will get deleted! Am I missing something? |
I was having great difficulties, so thank you very much!! |
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/lowdb@1.0.0/node_modules/lowdb/adapters/FileSync.js:53:14)
at db.write (/var/task/node_modules/.pnpm/lowdb@1.0.0/node_modules/lowdb/lib/main.js:37:21)
at /var/task/node_modules/.pnpm/json-server@0.17.0/node_modules/json-server/lib/server/router/write.js:5:8
at Layer.handle [as handle_request] (/var/task/node_modules/.pnpm/express@4.18.1/node_modules/express/lib/router/layer.js:95:5)
at next (/var/task/node_modules/.pnpm/express@4.18.1/node_modules/express/lib/router/route.js:144:13)
at create (/var/task/node_modules/.pnpm/json-server@0.17.0/node_modules/json-server/lib/server/router/plural.js:246:5)
at Layer.handle [as handle_request] (/var/task/node_modules/.pnpm/express@4.18.1/node_modules/express/lib/router/layer.js:95:5)
at next (/var/task/node_modules/.pnpm/express@4.18.1/node_modules/express/lib/router/route.js:144:13)
The text was updated successfully, but these errors were encountered: