2
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?

PromiseResultのみを取得したい

Last updated at Posted at 2025-02-19

はじめに

DBから取得した結果がPromiseのオブジェクトで返却されたとき、取得方法に困りました。

問題

Promiseで返却されるPrimiseResultのみを取得したかった。
image.png

解決方法

then()を使う。

  const [records, setRecords] = useState([]);
  useEffect(() => {
    const datas =  getAllDatas();
    datas.then((data) => {setRecords(data)});
  }, []);

image.png

おわりに

「PromiseResult 取得」でGoogle検索したところ解決しました。
検索の仕方も学んでいきたいです。

参考

2
1
2

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
2
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?