on master help sign in
search: trial with promise.all
commit168e8887f3f6f648a9f19a7cbc47f1428a2ebf0c authorMatilde Park <matilde.park@urbit.org> dateWed 6 Jul 2022, 18:43 (4 years ago) parent9c41a3a
1 file changed+9−3
components/Search.js+9−3
components/Search.js+9−3
@@ -87,7 +87,7 @@ class Search extends Component {
8787 ]
8888 : [];
8989
90− const glossaryResults = await fetch(this.glossarySearch(query))
90+ const glossarySearch = fetch(this.glossarySearch(query))
9191 .then((res) => res.json())
9292 .then((res) => {
9393 return res.results.map((item) => ({
@@ -96,7 +96,7 @@ class Search extends Component {
9696 }));
9797 });
9898
99− const devResults = await fetch(this.devSearch(query))
99+ const devSearch = fetch(this.devSearch(query))
100100 .then((res) => res.json())
101101 .then((res) => {
102102 return res.results.map((item) => ({
@@ -105,7 +105,7 @@ class Search extends Component {
105105 }));
106106 });
107107
108− const opsResults = await fetch(this.opsSearch(query))
108+ const opsSearch = fetch(this.opsSearch(query))
109109 .then((res) => res.json())
110110 .then((res) => {
111111 return res.results.map((item) => ({
@@ -114,6 +114,12 @@ class Search extends Component {
114114 }));
115115 });
116116
117+ const [glossaryResults, devResults, opsResults] = await Promise.all([
118+ glossarySearch,
119+ devSearch,
120+ opsSearch,
121+ ]);
122+
117123 const list = [
118124 ...glossaryResults,
119125 ...patpResult,