From bca405ec07e76890c96b91e4a030eb36fa0c811f Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Sat, 4 Feb 2017 08:58:34 -0600 Subject: [PATCH] End points require auth now. --- .../js/members/components/MemberTable/index.jsx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/bikeshop_project/assets/js/members/components/MemberTable/index.jsx b/bikeshop_project/assets/js/members/components/MemberTable/index.jsx index f99476c..fdab578 100644 --- a/bikeshop_project/assets/js/members/components/MemberTable/index.jsx +++ b/bikeshop_project/assets/js/members/components/MemberTable/index.jsx @@ -36,7 +36,7 @@ export default class MemberTable extends React.Component { } componentDidMount() { - fetch('/api/v1/members/') + fetch('/api/v1/members/', { credentials: 'same-origin' }) .then(checkStatus) .then(parseJSON) .then((data) => { @@ -63,11 +63,12 @@ export default class MemberTable extends React.Component { const value = this.state.searchText.trim(); const self = this; - fetch(`/members/search/${value}/`) + fetch(`/members/search/${value}/`, { credentials: 'same-origin' }) .then((response) => { if (response.status === 200) { return response.json(); } + throw new Error('Bad response from server'); }) .then((data) => { @@ -77,15 +78,11 @@ export default class MemberTable extends React.Component { error: '', filteredMembers: this.state.members.filter((member) => { const ids = data.results.map(m => m.id); - console.log(ids); - - if (ids.indexOf(member.id) !== -1) { - return member; - } + return ids.indexOf(member.id) !== -1; }), }); } else { - self.setState({ ...this.state, error: 'Member not found.' }); + self.setState({ ...this.state, filteredMembers: [], error: 'Member not found.' }); } }); } @@ -142,7 +139,7 @@ export default class MemberTable extends React.Component { {memberRows.length && !this.state.searchText ? memberRows : - {'Members loading.'} + {this.state.error || 'Members loading.'} }