Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fetchForLater().then( resp => {
if ( !resp.ok ) { throw new Error( "Failed to fetch for later people" ); }
return resp.json();
} ).then( json => {
const savedForLater = json.map( ( [ id, person ] ) => person );
this.setState( { saved: savedForLater } );
} );
saveForLater( person ).then( resp => {
if ( !resp.ok ) {
throw new Error( "Failed to save person for later" );
}
} ).then( () => {
const saved = this.state.saved;
saved.push( person );
this.setState( { saved } );
} ).catch( err => {
alert( err.message );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.