https://github.com/truecodersio/node_streams
https://github.com/truecodersio/node_streams
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/truecodersio/node_streams
- Owner: truecodersio
- Created: 2021-03-15T22:08:03.000Z (over 5 years ago)
- Default Branch: Answer
- Last Pushed: 2022-02-16T21:06:07.000Z (over 4 years ago)
- Last Synced: 2025-03-24T18:06:08.688Z (over 1 year ago)
- Language: JavaScript
- Size: 62.5 KB
- Stars: 0
- Watchers: 1
- Forks: 27
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Exercise
## Part 1
- In VS Code, create and open a new folder named “node_streams”
- Create a streams.js file
- Import or require the fs module
- Create a server
- Write a conditional statement that checks the request url for a “GET” request on a “/”
- If the method and url match the previous check (step c), use createReadStream to pipe the contents of an html file to the client
- You can design the html file however you choose
- If the method and url are not “/” and “GET”, use the same method to pipe the contents of a 404 not found html page
- You should send the appropriate status code and headers
- Now run node app and test in postman or the browser
## Part 2
- In a new file, fetch data from a source of your choosing (e.g. [Pokemon](“https://raw.githubusercontent.com/Biuni/PokemonGO-Pokedex/master/pokedex.json”))
- Use the createWriteStream method to create a write stream using an empty json file in your project
- Use the write method to populate the json file with the data from your fetch request
### HINT
- You will need to use a third-party fetch api (isomorphic-fetch, node-fetch, Axios, etc) to achieve this in Node