Skip to content

Commit

Permalink
Member grid backend connection (#49)
Browse files Browse the repository at this point in the history
* added comments to Table.js for backend connection

* added api call to get all members

* -fixed member state variable

Co-authored-by: Alice Fang <[email protected]>
  • Loading branch information
2 people authored and n3a9 committed May 23, 2021
1 parent 6fed129 commit 9bcdaa8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions client/src/components/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const Table = () => {
const [members, setMembers] = useState([]);
useEffect(() => {
const getAllMembers = async () => {
const allMembers = await getMembers()
setMembers(allMembers)
const allMembers = await getMembers();
setMembers(allMembers.data.result);
};
getAllMembers();
}, []);
Expand Down
15 changes: 15 additions & 0 deletions client/src/utils/apiWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ export const getMemberSchemaTypes = () => {
}));
};

// Retrieves all members
export const getMembers = () => {
const requestString = `${BACKEND_BASE_URL}/members`;
return axios
.get(requestString, {
headers: {
'Content-Type': 'application/JSON',
},
})
.catch((error) => ({
type: 'GET_MEMBERS_FAIL',
error,
}));
};

// Retrieves a member's permissions from their mongo ID
export const updateMember = (member, memberID) => {
const requestString = `${BACKEND_BASE_URL}/members/${memberID}`;
Expand Down

0 comments on commit 9bcdaa8

Please sign in to comment.