0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JSON Server + ngrok

Last updated at Posted at 2020-04-12

前提

Json Server

ngrok

使い方

1. json-serverとngrokのインストール

mkdir jsonserver && cd jsonserver npm init npm install json-server ngrok

2. db.jsonの作成

db.json
{
  "posts": [
    {   
      "id": 1,
      "title": "Post title 1"
    }
  ],
  "comments": [
    { "id": 1, "body": "comment 1", "postId": 1 }
  ]
}

3. package.jsonの中から "scripts"の部分変更

  "scripts": {
    "db": "json-server -w db.json -p 3001",
    "tunnel": "ngrok http 3001"
  },

4. json-serverとngrokの起動

ターミナルをもう一つ起動し、それぞれのターミナルで下記の2つのコマンドを実行。

npm run db npm run tunnel

5. データ確認

$ curl http://###.ngrok.io/posts/1
{
  "id": 1,
  "title": "Post title 1"
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?