|
|
@ -176,11 +176,10 @@ class User {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** first method */
|
|
|
|
/** first method - take a story instance and insert into our array
|
|
|
|
//take a story instance and insert into user favorite array...
|
|
|
|
* of favorites for a partiuclar user
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
//what information should appear in this array?
|
|
|
|
|
|
|
|
//my guess is some story information, information to load story later
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async insertStoryIntoFavorites(story) {
|
|
|
|
async insertStoryIntoFavorites(story) {
|
|
|
|
|
|
|
|
|
|
|
@ -189,16 +188,28 @@ class User {
|
|
|
|
method: "POST",
|
|
|
|
method: "POST",
|
|
|
|
data: { token: `${currentUser.loginToken}` }
|
|
|
|
data: { token: `${currentUser.loginToken}` }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
console.log("our response from the api post ...", response);
|
|
|
|
|
|
|
|
// currentUser.favorites.push(story);
|
|
|
|
return currentUser.favorites.push(story);
|
|
|
|
console.log("what's inside my favorite list... ", currentUser.favorites);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** second method */
|
|
|
|
/** second method - take a story instance and remove it from our array of
|
|
|
|
|
|
|
|
* favorited articles
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async removedStoryFromFavorites(story) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const response = await axios({
|
|
|
|
|
|
|
|
url: `${BASE_URL}/users/${currentUser.username}/favorites/${story.storyId}`,
|
|
|
|
|
|
|
|
method: "DELETE",
|
|
|
|
|
|
|
|
data: { token: `${currentUser.loginToken}` }
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return currentUser.favorites;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|