Skip to content

Instantly share code, notes, and snippets.

@jermsam
Created May 1, 2019 01:29
Show Gist options
  • Save jermsam/3fcd978fe70530adcfa0ccf4aaff3927 to your computer and use it in GitHub Desktop.
Save jermsam/3fcd978fe70530adcfa0ccf4aaff3927 to your computer and use it in GitHub Desktop.
app
.service('stories')
.find()
.then(({ data }) =>
data.map(({ title, goal, user }) => {
console.log(user);
if (user) {
const { id, avatar, firstname, lastname } = user;
return {
id,
title: `${firstname} ${lastname}`,
image: `${this.processSource(avatar)}`,
description: `${title}`,
price: `$ ${goal}`
};
}
// const { title, goal } = story;
return {
id: null,
title: ``,
image: ``,
description: ``,
price: ``
};
})
)
.then(source => {
const { student } = this.state;
if (student.length < 1) return this.resetComponent();
const re = new RegExp(_.escapeRegExp(student), 'i');
const isMatch = result => re.test(result && result.title);
if (this._isMounted) {
this.setState({
isLoading: false,
results: _.filter(source, isMatch)
});
}
return null;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment