|
|
@ -176,29 +176,40 @@ 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) {
|
|
|
|
|
|
|
|
|
|
|
|
const response = await axios({
|
|
|
|
const response = await axios({
|
|
|
|
url: `${BASE_URL}/users/${currentUser.username}/favorites/${story.storyId}`,
|
|
|
|
url: `${BASE_URL}/users/${currentUser.username}/favorites/${story.storyId}`,
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|