Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9130

Node.js: fetch の使い方

$
0
0
こちらを参考にしました。 node-fetch / node-fetch ライブラリーのインストール sudo npm install -g node-fetch fetch01.js #! /usr/bin/node import fetch from 'node-fetch' const url = 'https://api.github.com/users/ekzemplaro' const response = await fetch(url) const body = await response.text() console.log(body) 実行結果 $ ./fetch01.js | jq { "login": "ekzemplaro", "id": 7269588, "node_id": "MDQ6VXNlcjcyNjk1ODg=", "avatar_url": "https://avatars.githubusercontent.com/u/7269588?v=4", "gravatar_id": "", "url": "https://api.github.com/users/ekzemplaro", "html_url": "https://github.com/ekzemplaro", "followers_url": "https://api.github.com/users/ekzemplaro/followers", "following_url": "https://api.github.com/users/ekzemplaro/following{/other_user}", "gists_url": "https://api.github.com/users/ekzemplaro/gists{/gist_id}", "starred_url": "https://api.github.com/users/ekzemplaro/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/ekzemplaro/subscriptions", "organizations_url": "https://api.github.com/users/ekzemplaro/orgs", "repos_url": "https://api.github.com/users/ekzemplaro/repos", "events_url": "https://api.github.com/users/ekzemplaro/events{/privacy}", "received_events_url": "https://api.github.com/users/ekzemplaro/received_events", "type": "User", "site_admin": false, "name": "Uchida Masatomo", "company": null, "blog": "https://ekzemplaro.org", "location": "Tochigi,Japan", "email": null, "hireable": null, "bio": null, "twitter_username": null, "public_repos": 33, "public_gists": 0, "followers": 3, "following": 0, "created_at": "2014-04-12T03:29:10Z", "updated_at": "2022-02-10T08:40:41Z" }

Viewing all articles
Browse latest Browse all 9130

Trending Articles