testing function addStory

main
Jason 2 years ago
parent 0ff9b8b1ea
commit 6f3f59e19c

@ -73,7 +73,7 @@ class StoryList {
* Returns the new Story instance * Returns the new Story instance
*/ */
async addStory(user, newStory) { async addStory(/*user, newStory*/) {
// UNIMPLEMENTED: complete this function! // UNIMPLEMENTED: complete this function!
/* /*
user = ("theCat"); user = ("theCat");
@ -85,13 +85,26 @@ class StoryList {
let newStory = await storyList.addStory(currentUser, let newStory = await storyList.addStory(currentUser,
{title: "Test", author: "Me", url: "http://meow.com"}); {title: "Test", author: "Me", url: "http://meow.com"});
*/ */
const response = await axios({ let user = { userObj:
url: `${BASE_URL}/stories`, { username: "lilithcat",
method: "POST", name: "lilithcat",
params: {"token": user.loginToken, "story": } createdAt: "2022-06-02T19:03:57.323Z",
}) favorites: [],
ownStories: [],
} }, loginToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImxpbGl0aGNhdCIsImlhdCI6MTY1NDE5NjYzN30.cXb98zmezSguUU2NJqBKy7Oi44KAPY970HTF1LWKMNE"};
let newStory = {
"author": "Matt Lane",
"title": "The best story ever",
"url": "http://google.com",
};
const response = await axios.post(
`${BASE_URL}/stories`,
{ params: { token: user.loginToken, story: newStory } }
);
console.log("made it after the axios call");
return response;
}
} }
@ -106,13 +119,13 @@ class User {
*/ */
constructor({ constructor({
username, username,
name, name,
createdAt, createdAt,
favorites = [], favorites = [],
ownStories = [] ownStories = []
}, },
token) { token) {
this.username = username; this.username = username;
this.name = name; this.name = name;
this.createdAt = createdAt; this.createdAt = createdAt;

Loading…
Cancel
Save