Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/p1xt/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.
https://github.com/p1xt/express-demo
dom-manipulation express fetch pug
Last synced: 28 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/p1xt/express-demo
- Owner: P1xt
- Created: 2018-02-17T18:47:23.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-17T19:13:01.000Z (almost 7 years ago)
- Last Synced: 2024-10-14T13:23:56.297Z (3 months ago)
- Topics: dom-manipulation, express, fetch, pug
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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, etcI 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.