From 6f3f59e19c3888b52a5a5fd94058981cc7d46406 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 2 Jun 2022 20:12:47 -0500 Subject: [PATCH] testing function addStory --- js/models.js | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/js/models.js b/js/models.js index 14e0ec9..7b277fa 100644 --- a/js/models.js +++ b/js/models.js @@ -73,7 +73,7 @@ class StoryList { * Returns the new Story instance */ - async addStory(user, newStory) { + async addStory(/*user, newStory*/) { // UNIMPLEMENTED: complete this function! /* user = ("theCat"); @@ -85,13 +85,26 @@ class StoryList { let newStory = await storyList.addStory(currentUser, {title: "Test", author: "Me", url: "http://meow.com"}); */ - const response = await axios({ - url: `${BASE_URL}/stories`, - method: "POST", - params: {"token": user.loginToken, "story": } - }) - - } + let user = { userObj: + { username: "lilithcat", + name: "lilithcat", + 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({ - username, - name, - createdAt, - favorites = [], - ownStories = [] - }, - token) { + username, + name, + createdAt, + favorites = [], + ownStories = [] + }, + token) { this.username = username; this.name = name; this.createdAt = createdAt;