File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,6 +67,31 @@ export const getMembersCollection = (): Promise<MemberEntity[]> => {
6767+ }));
6868```
6969
70+ - Adding async await calling member api
71+
72+ To make the async await work, we should install
73+ - ` npm install -D @babel/plugin-transform-runtime `
74+ - ` npm install -P @babel/runtime `
75+
76+ and add to the .babelrc
77+
78+ _ .babelrc_
79+ ``` bash
80+ " plugins" : [" @babel/plugin-transform-runtime" ]
81+ ```
82+
83+ _ ./src/components/memberTable.tsx_
84+ ``` diff
85+ - const loadMemberCollection = () => {
86+ - getMembersCollection().then(memberCollection =>
87+ - setMemberCollection(memberCollection)
88+ - );
89+
90+ + const loadMemberCollection = async () => {
91+ + const memberCollection = await getMembersCollection();
92+ + setMemberCollection(memberCollection);
93+ ```
94+
7095- Aaaand... we don't need to add any update on the rest of the application, why?
7196 The function is providing the same contract, it returns a promise<MemberEntity[ ] >,
7297 let's give a try:
You can’t perform that action at this time.
0 commit comments