Skip to content

Instantly share code, notes, and snippets.

@tristankirkpatrick
Created August 13, 2019 09:03
Show Gist options
  • Save tristankirkpatrick/3cce03345f102473799583d4b375f178 to your computer and use it in GitHub Desktop.
Save tristankirkpatrick/3cce03345f102473799583d4b375f178 to your computer and use it in GitHub Desktop.
new Vue({
el: "#app",
data: function () {
return {
filter: "",
sort: "",
options: [
{ label: "Recently Added", value: "none" },
{ label: "Most Followers", value: "followers_count" }],
teachers: [] };
},
created() {
axios.
get("http://192.168.1.150:8080/twitterteachers/teachers").
then(({ data }) => {
this.teachers = data;
});
},
computed: {
getTeachers() {
var teachers = this.teachers.filter(teacher => {
return teacher.name.toLowerCase().includes(this.filter.toLowerCase());
});
if (this.sort == "followers_count") {
return teachers.sort(function (a, b) {
return b.followers_count - a.followers_count;
});
} else {
return teachers;
}
} } });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment