Json-server Usage Summary

Source: Internet
Author: User

Json-server Usage Summary

What: Forge Online rest APIs, provide virtual data to front-end pages, support Cors and JSONP cross-domain requests, support get, POST, PUT, PATCH, and DELETE methods

How-to-use method one: Call online using an on-line address

After entering the online address http://jsonplaceholder.typicode.com/, a variety of analog data interfaces are available at the bottom of the page for us to call directly

, the fields in the interface and the data structures are fixed, and we can't change them to fit our scenario, so we can use Json-server to simulate the data locally and write the JSON file according to our own needs.

Use method Two: Use Json-server local call

First, the global installation: in the installation of Nodejs premise, open the terminal, the global installation Json-server

NPM install-g Json-server

Second, initialize: Create a new Folder project and CD into project, initialize the Package.json file

NPM Init

Third, confirm package information: Enter to confirm name,version and so on, generate Package.json file

Four, install Json-server module, after success, Package.json will display the version number

NPM Install Json-server--save

V. Create Data.json in folder project and write JSON data as needed

Vi. monitoring Data.json files, "My-server" for custom names

Seven, the address below the start Json:my-server,resource is the generated local interface address

NPM Run Json:my-server


Eight, in addition to their own local simulation JSON data, you can also remotely introduce Jsonplaceholder data



Nine, if the interface address too many, you can create a new Readme.txt, copy it for inspection


Ten, when the interface data returned too much, inconvenient to consult, can use postman consult


Json-server Usage Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.