0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Typescript】入れ子状のオブジェクトから分割代入する方法を学んだ

Posted at

背景

乱数で7けたの数字を生成し、それを郵便番号として住所を検索するのを試みていた。
APIとしてzipcloudを使用。
なお従来は res.data.resultsのように取り出していた

学んだこと

分割代入で以下のように取り出せるそう

Post.tsx
const {data: {results}} = await axios.get(requestUrl);

レスポンスのデータ形式

以下の通り。

config:
data: 
  message: 
  results:
  status: 
headers: 
request: 
...
0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?