GithubHelp home page GithubHelp logo

p1xt / express-demo Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 23 KB

Minimal express.js app to demonstrate the use of fetch with a Pug/Jade template to retrieve data from a REST API served by other routes on the Express app.

JavaScript 58.98% CSS 23.08% HTML 17.93%
express pug fetch dom-manipulation

express-demo's Introduction

Express Demo

Minimal express.js app to demonstrate the use of fetch with a Pug/Jade template to retrieve data from a REST API served by other routes on the Express app.

Where the interesting stuff happens:

  • Look in views/index.pug for an example of pulling JavaScript files into the Pug template.

  • Look in public/javascripts/get_animal.js for an example of using fetch to perform a GET request against the API, then using JavaScript to update DOM elements based on the result.

To run

  • clone or download
  • cd express-demo
  • npm install
  • npm start

Important to note: This is a minimal example, intended only to illustrate the use of fetch within a Pug template, and vanilla JavaScript methods for manipulating the DOM with the results. There are a bunch of other things that are beyond the scope of demonstrating fetch that would be necessary for a production quality application that I've elected not to include as they'd add a lot of extra bulk, without adding any clarity to the demo. Namely:

  • Unit testing
  • Production bundling
  • Dev reloading
  • etc, etc, etc

I know the other stuff is important - but it would have added a lot of noise to sift through to get to the code this repo is actually meant to illustrate.

express-demo's People

Contributors

p1xt avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.