<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # 模擬 REST 服務器來偽造在線 API > 原文: [https://howtodoinjava.com/angular/mock-rest-server/](https://howtodoinjava.com/angular/mock-rest-server/) 學習**在本地創建模擬 REST 服務器**,該服務器將**模擬在線 REST API**,并在線生成所需的 JSON 響應。 擁有這樣的 REST API 模擬功能非常方便,可以縮短開發時間。 ## 安裝 JSON 服務器 在 Node 和 Angular 開發環境中,讓我們導入`json-server`依賴項。 ```java $ npm install -g json-server //Console Output C:\Users\admin\AppData\Roaming\npm\json-server -> C:\Users\admin\AppData\Roaming\npm\node_modules\json-server\bin\index.js + json-server@0.14.0 added 229 packages from 130 contributors in 24.844s ``` ## 創建模擬 JSON 響應并提供在線服務 1. 關于這種方法的最好的事情是,您不會被迫消耗任何意味著更少數據的虛擬對象。 相反,您可以**創建要使用的 JSON 數據**,并將其放入文件`'db.json'`中并開始提供它。 ```java { "employees": [ { "id": 1, "name": "Lokesh", "status": "active" }, { "id": 2, "name": "Andy", "status": "Inactive" }, { "id": 3, "name": "Brian", "status": "active" }, { "id": 4, "name": "Charles", "status": "Inactive" } ] } ``` 2. 并使用簡單的命令開始在`db.json`文件上方投放。 ```java $ json-server --watch 'E:\ngexamples\db.json' \{^_^}/ hi! Loading E:\ngexamples\db.json Done Resources http://localhost:3000/employees Home http://localhost:3000 Type s + enter at any time to create a snapshot of the database Watching... ``` 3. 現在使用命令在瀏覽器中測試 REST API `'http://localhost:3000/employees'`. ![JSON server running](https://img.kancloud.cn/9b/22/9b22573f75575b52ee2e0875f7db80d0_397x405.png) JSON 服務器運行中 > 請注意,由 JSON 服務器提供的 REST 端點由`db.json`中的數據節點確定。 它是如此簡單而強大。 將我的問題放在評論部分。 學習愉快! 參考: [json 服務器 github 頁面](https://github.com/typicode/json-server)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看