![【リソース取得APIの比較】fetchとaxiosの4つの相違点](https://cdn-ak-scissors.b.st-hatena.com/image/square/0930d877f1a528729fdb8846b5d28feb70462f97/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fzenn%2Fimage%2Fupload%2Fs--Xd3y2Ade--%2Fc_fit%252Cg_north_west%252Cl_text%3Anotosansjp-medium.otf_55%3A%2525E3%252580%252590%2525E3%252583%2525AA%2525E3%252582%2525BD%2525E3%252583%2525BC%2525E3%252582%2525B9%2525E5%25258F%252596%2525E5%2525BE%252597API%2525E3%252581%2525AE%2525E6%2525AF%252594%2525E8%2525BC%252583%2525E3%252580%252591fetch%2525E3%252581%2525A8axios%2525E3%252581%2525AE4%2525E3%252581%2525A4%2525E3%252581%2525AE%2525E7%25259B%2525B8%2525E9%252581%252595%2525E7%252582%2525B9%252Cw_1010%252Cx_90%252Cy_100%2Fg_south_west%252Cl_text%3Anotosansjp-medium.otf_37%3A%2525E3%252581%252597%2525E3%252582%252585%2525E3%252581%252586%252Cx_203%252Cy_121%2Fg_south_west%252Ch_90%252Cl_fetch%3AaHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL3plbm4tdXNlci11cGxvYWQvYXZhdGFyL2M2ZmI2MzMyZjAuanBlZw%3D%3D%252Cr_max%252Cw_90%252Cx_87%252Cy_95%2Fv1627283836%2Fdefault%2Fog-base-w1200-v2.png)
So I recently had to make some changes to a React code base that was fairly unfamiliar to me. My task was to make a PUT API request to an external endpoint, in order to update a user profile upon a certain state being toggled on. It seemed like an easy enough task as I knew I could just tap into the installed axios package to make API calls... until I opened up the code repo and saw abstraction up
「【初心者向き】AxiosによるWeb APIへのアクセス方法~その① Axiosの使い方」の続きになります。 まずは前回のプログラム(医療機器の識別子を与えるとブランド名を返す)を複数呼び出せるように関数にします。 const axios = require('axios'); // 医療機器の識別子からブランド名を取得する const getSingleDeviceRecord = async (di) => { const url = `https://accessgudid.nlm.nih.gov/api/v2/devices/lookup.json?di=${di}`; try { const res = await axios.get(url); return res.data.gudid.device.brandName; } catch (error) { return e
GitHubリポジトリ 発音はアクシオスのようです。 http://ejje.weblio.jp/content/Axios 戻り値がPromiseベースなのでjQueryの$.ajaxやFetch APIのように使える ブラウザだけでなくNode.jsでも使える 使い方 npmからaxiosをインストールします。 const axios = require('axios'); const url = "https://qiita.com/api/v2/items"; axios.get(url).then(res => { const items = res.data; for (const item of items) { console.log(`${item.user.id}: \t${item.title}`); } }).catch(error => { const { sta
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く