This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const request = async ( type ) => { | |
const endpoint = endpoints[ type ] || type | |
const results = await requestEndpoint([], { endpoint, offset: null }) | |
return results | |
} | |
const requestEndpoint = async ( list = [], { endpoint, offset } ) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Maybe(() => data.personsFirstName[0].value) | |
.then( | |
value => console.log(value), | |
error => console.error(error) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Maybe(() => data.personsFirstName[0].value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fullname.then( | |
name => console.log( name ), | |
err => console.warn( err ) | |
) | |
// Lastname was not found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lastname = Maybe(() => data.personsLastName[1].value) | |
.catch( _ => Promise.reject('Lastname was not found') ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lastname = Maybe(() => data.personsLastName[1].value) | |
.catch( _ => 'Lastname' ) | |
const fullname = firstname | |
.then( fname => middleName.then( mname => `${fname} ${mname}`) ) | |
.then( name => lastname.then( lname => `${name} ${lname}` ) ) | |
// 'Marcus Geoffrey Lastname' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fullname = firstname | |
.then( fname => middleName.then( mname => `${fname} ${mname}`) ) | |
.then( name => lastname.then( lname => `${name} ${lname}` ) ) | |
fullname.then( name => console.log( name ) ) | |
// 'Marcus Geoffrey Johnson' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const firstname = Maybe(() => data.personsFirstName[0].value) | |
.catch( _ => 'Firstname' ) | |
const middleName = Maybe(() => data.personsMiddleName[0].value) | |
.catch( _ => 'Middlename') | |
const lastname = Maybe(() => data.personsLastName[0].value) | |
.catch( _ => 'Lastname' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const data = { | |
personsFirstName :[ | |
{ value : 'Marcus' } | |
], | |
personsMiddleName :[ | |
{ value : 'Geoffrey' } | |
], | |
personsLastName:[ | |
{ value : 'Johnson' } | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Maybe(() => data.personsFirstName[0].value) | |
.then( | |
value => console.log(value), | |
error => console.error(error) | |
) |
NewerOlder