Coder Social home page Coder Social logo

node_streams's Introduction

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)
  • 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

node_streams's People

Contributors

jkpeople avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.