This repository was archived by the owner on Aug 17, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 440
London Class 9 - Natalie Zablotska - Node - Week 2 #275
Open
nataliiazab
wants to merge
12
commits into
CodeYourFuture:master
Choose a base branch
from
nataliiazab:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6118ef1
Updated Level 1 Challenge
nataliiazab 504fb1f
completed level1
nataliiazab 0c50489
Completed Level 2
nataliiazab 3f3f613
Level 3 in progress
nataliiazab b3a0c5b
added put method
nataliiazab de5a1c8
fixed a bug in put
nataliiazab 5cddb38
added fs in the header
nataliiazab 879818c
Update server.js
nataliiazab 22e1b08
assigned port to a variable
nataliiazab c813daf
added app.delete to /people:name route
nataliiazab bd14719
added if statements with error to /messages/:id put route
nataliiazab 562302c
Added a comment to ask about the port later
nataliiazab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <html> | ||
| <body> | ||
| <h1 id="heading"></h1> | ||
| <script> | ||
| fetch("http://localhost:3000/people") | ||
| .then((response) => response.json()) | ||
| .then((data) => (document.getElementById("heading").innerHTML = data)); | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| const express = require("express"); | ||
|
|
||
| const app = express(); | ||
| app.use(express.json()); | ||
|
|
||
| let people = ["Jason"]; | ||
|
|
||
| app.get("/people", (request, response) => { | ||
| response.setHeader("Access-Control-Allow-Origin", "*"); | ||
| response.json(people); | ||
| }); | ||
|
|
||
| app.put("/people", (request, response) => { | ||
| people.push(...request.body); | ||
| response.json(people); | ||
| }); | ||
|
|
||
| app.delete("/people", (request, response) => { | ||
| res.send("DELETE Request Called"); | ||
| }); | ||
|
|
||
| app.listen(3000, () => { | ||
| console.log("listening on port 3000"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. assign port number in a variable so you can refer to it in your console message.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks Jack, done :) |
||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to try to use VSCode's code formatting function (press CMD/CTRL + P, then enter "> format" at the prompt box)
Are you deleting an element from the
peoplearray? Did you miss capturing the id from url?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for noticing - I've finished it now! Didn't know about CTRL + P + '> format', will learn more about this toll now. Thank you!