Day 46

in #code7 years ago

February 28th, 2018

Hello! At the ES6 course by Wes Bos I started to learn about Async, but first we actually review the Promises. We canuse the fetch api to get data, together with then, and we also have to turn it into json

       fetch('https://api.github.com/users/wesbos').then(res => {
     }).then(res => {
    }).catch(err => {
         console.error(err);
     })

    navigator.mediaDevices.getUserMedia({video:true}).then(mediaStream => {
        video.srcObject = mediaStream;
        video.load();
        video.play();
    }).catch(err =>{
    console.log(err);
    });

At the Web Development Bootcamp we learned about how to include assets like css ors js file.
We don’t need to write css in every single file, but instead we can create a static file and connected it with the other pages. We have to add this to the app.js

         app.use(express.static("public"));

This one we add so that we don’t have to write ejs. after every file.

        app.set("view engine", "ejs");

Partials are files that we can include in other templates. We can make a header and footer file for example and store all the boiler plate and add it to the other pages.

         <% include partials/header %>
         <% include partials/footer %>

/app - paths are very important!

Cheers!

Coin Marketplace

STEEM 0.31
TRX 0.26
JST 0.039
BTC 94701.89
ETH 3372.96
USDT 1.00
SBD 3.30