POST request to a local json file using HttpClient

后端 未结 2 877
清歌不尽
清歌不尽 2020-12-21 23:49

I have one json file named fake.json inside assets in my angular application. Path of this file is like this.

MyApp => s

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-22 00:23

    In order to read or write data from a local JSON file, you can use json-server.

    1. Create fake.json file.
    2. Install json-server npm i json-server.
    3. Start the JSON Server json-server --watch fake.json.
    4. Now request the server on http://localhost:3000/

    Follow the documentation link: https://www.npmjs.com/package/json-server

提交回复
热议问题