Chrome Dev Tools
If you want to check how your requests are being sent, and what the responses are from the browser, you can do so using Chrome Dev Tools. There are numerous tools within it, but the key area you will use is the Network tab.
Curl

Curl is a library and command-line tool that completes IP transfers of data using URLs. One quick way to test your API while your API server is running is to run a curl command in another terminal window.
Curl syntax
$ curl -X POST http://www.example.com/tasks/
The above is a sample curl request. Every request starts off with the command curl and needs to include a URL. Other parts you see added in are options that you can use to build your request. In the example, the -X shortform option (also –request) specifies the request method.

Curl Options
You can find more options by entering the following command in the terminal:
$ curl --help
Try piping the output to the jq, a command-line JSON processor, as shown below:
$ curl https://example/test | jq '.'
如果在Terminal顯示不了,可以用這個網站來看JSON result
查詢curl結果
Art of Scripting HTTP Requests Using Curl
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/400497.html
標籤:其他
下一篇:計算機網路期末考試大題(一)
