Questions tagged [json-server]

json-server allows you to rapidly create a REST API server that delivers JSON data.

json-server is a tool written in that allows you to rapidly create a server that when started up, delivers json data via a API.

You can use json-server for rapid prototyping and mocking out other REST API services.

Supply a JSON file to describes the JSON data and the API that will deliver it and json-server will start up a server that provides that data via a REST API

Source Code and further documentation https://github.com/typicode/json-server

Installation npm install json-server

Egghead Video (free) Nodejs: Creating demo apis with json-server

477 questions
3
votes
2 answers

Correct code flow: dispatch actions and block, or verify in advance if dispatch them?

this is my first question on Stackoverflow after one year of Front-end development self-learning. I've already serached foe an answer to my doubts, but since these questions are returning for the third time, I think it's the moment to ask the…
ncasteln
  • 109
  • 1
  • 5
3
votes
1 answer

API call not reaching Vite proxy target (localhost:5000)

So I'm trying to learn Vue and I've set up a project and a json-server backend, both running with Docker. Almost everything is working as intended. I've written a function to fetch the tasks in the json backend: async fetchTasks(){ const res =…
brungran
  • 31
  • 4
3
votes
3 answers

json-server running but can't access its api due to 403

Learning reactjs, trying to simulate a server with json-server this is my script to run the server: "scripts": { "server": "json-server --watch db.json --port 5000" }, running this on terminal npm run server output: Debugger listening on…
Alon Aviram
  • 190
  • 1
  • 15
3
votes
1 answer

Can't install json-server

I am trying to install JSON-Server, but it's not working! I have used the following command: npm install -g json-server Here is the error message: npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /usr/local/lib/node_modules/json-server npm…
Egor Ulybin
  • 57
  • 1
  • 6
3
votes
4 answers

How to use json-server | Getting 404 for local db.json

I'm pretty sure doing everything correctly. I'm using these version: "axios": "^0.24.0", "json-server": "^0.17.0", I've followed the official doc. I've db.json in the root folder itself. { "users": [ { "ID": 1, "Username": "mike", …
Tanzeel
  • 4,174
  • 13
  • 57
  • 110
3
votes
0 answers

How to return value from json-server on post request?

The issue GET /api/get-request works correctly, and `{ x: 'x' } is returned to the frontend POST /api/post-request works too but returns empty body How I run json-server: json-server src/configs/api/mocks/json-server-generator.js --routes…
dragonmnl
  • 14,578
  • 33
  • 84
  • 129
3
votes
0 answers

Vue and Json-server hosted on Vercel

I'm currently writing frontend app in Vue.js. Until I have a real web API, I've decided to use json-server. Now I'm trying to configure Vercel to start my json-server alongside Vue during deployment. Using concurrently "json-server --watch db.json"…
3
votes
2 answers

no cors config not working with json-server

I'm using json-server to create a mock API of my actual API for offline testing purpose. I can see the mock API response under their Url endpoint: localhost:5001/api/searchresults/* but on my app I cannot see the results because the request is…
Giorgia Sambrotta
  • 1,133
  • 1
  • 15
  • 45
3
votes
2 answers

jsonserver not redirecting using rewriter

I have an employees endpoint with some data in my db.json. I'm using node v6.14.9. My server.js looks like this: // server.js const jsonServer = require('json-server') const server = jsonServer.create() const router =…
user3921104
  • 154
  • 13
3
votes
0 answers

React Admin - ReferenceInput with multiple fields output

I'm using React with React Admin to populate my database in which I have 2 collections: products and stores I need to link a store to the product, so normally I should do:
Mattia M.
  • 464
  • 1
  • 4
  • 16
3
votes
0 answers

How we can deploy or host our JSON-SERVER API?

I have implemented one react template with static data for learning purpose only. And deployed in github. For data I have created one json file in directory. But this file is not reacted as a API, Means I can't perform post, put and filter…
Varun Sharma
  • 4,632
  • 13
  • 49
  • 103
3
votes
3 answers

JSON-server connection breaks

I'm using GET and POST requests to apply RESTful conventions multiple times in my application. But this results in breaking my JSON-server connection. Does anyone know what is the reason behind this? Any idea that why I'm facing this problem? Error…
Knowledge Seeker
  • 526
  • 7
  • 25
3
votes
1 answer

json-server with express/ db.json is not reflecting changes

We are having a simple json-server setup, loading it as a module. However, when making a POST/PUT request, the data is not being injected into the db.json. const jsonServer = require("json-server"); const source = require("./db.json"); const repl =…
Ikarus93
  • 41
  • 4
3
votes
0 answers

Json server crash upon reload

I am using json-server as a mock API for my rxjs app. I am having problems when sending multiple PUT requests. When I send 2 or more PUT requests the server crashes and the terminal displays the following : PUT /terms/1 200 22.881 ms - 58 PUT…
3
votes
4 answers

Already installed JSON Server But show message Command Not Found

I already installed in other computers by npm the json-server. But on my MacBook Pro the command was run with successful and when I will execute the command json-server db.json is showed the message: Errors Screenshot My versions: node -v and npm…
Andre Conjo
  • 41
  • 1
  • 8
1 2
3
31 32