#when you want deploy your project with json-server on vercel or render mayby you will have problems to run your application becouse you use json server and need run this server to load your data for this reson you can use this code and create your endpoint to get post and other http requests
- Create a folder
mkdir json-server
cd json-server
npm init -y
npm i json-server
const jsonServer = require('json-server')
const server = jsonServer.create()
const router = jsonServer.router('db.json')
const middlewares = jsonServer.defaults()
server.use(middlewares)
server.use('/api', router)
server.listen(process.env.PORT || 5000, () => {
console.log('JSON Server is running')
})
{
"articles": [
{
"id": 1,
"title": "Example Article",
"content": "This is an example."
},
{
"id": 2,
"title": "Second Article",
"content": "This is also an example."
},
{
"title": "Third Article",
"content": "Another example!",
"id": 3
}
]
}
node server.js
http://localhost:5000/api/articles