From 8673a7fdad86a77366f8bc9d4264400fe85e65cc Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 3 Jun 2022 12:46:22 -0500 Subject: [PATCH] work finished through 2b on exercise checklist --- index.html | 169 +++++++++++++++++++++++++------------------------- js/models.js | 10 +-- js/stories.js | 10 ++- 3 files changed, 96 insertions(+), 93 deletions(-) diff --git a/index.html b/index.html index c2c4970..d0160d7 100644 --- a/index.html +++ b/index.html @@ -19,11 +19,8 @@ Hack or Snooze - + @@ -32,89 +29,91 @@ - - - - -
- - -
Loading…
- - -
    - -
    - - -
    - - - - -
    - - - - - - - - - - + + + +
    + + +
    Loading…
    + + +
      + +
      + + +
      + + + + + + + + + +
      + + + + + + + + + + + diff --git a/js/models.js b/js/models.js index f7b6396..dbf5b06 100644 --- a/js/models.js +++ b/js/models.js @@ -77,16 +77,16 @@ class StoryList { console.log("addStory called"); console.log("user.loginToken = ", user.loginToken); - const response = await axios.post( - `${BASE_URL}/stories`, + const response = await axios.post( + `${BASE_URL}/stories`, - { token: user.loginToken, story: newStory } - ); + { token: user.loginToken, story: newStory } + ); console.log("the response is : ", response); return new Story(response.data.story); - } + } } diff --git a/js/stories.js b/js/stories.js index 24a56ed..a522786 100644 --- a/js/stories.js +++ b/js/stories.js @@ -73,13 +73,17 @@ async function getNewStoryAndSubmit(evt) { title: title, author: author, url: url - } + }; // instantiate a Story with obj and display on page const resultOfAddStoryCall = await storyList.addStory(currentUser, newStory); console.log("resultOfAddStoryCall: ", resultOfAddStoryCall); hidePageComponents(); - putStoriesOnPage(); + await getAndShowStoriesOnStart(); + + //resets form with empty values + $addStoryForm.trigger("reset"); } -$addStoryForm.on("submit", getNewStoryAndSubmit); \ No newline at end of file +//event listener for add story form submit +$addStoryForm.on("submit", getNewStoryAndSubmit);