Basic Node and Express - Serve Static Assets

Tell us what’s happening:
okay why is not working it should be receiving the data from the public folder

Your code so far
let express = require(‘express’);
let app = express();
console.log(“Hello World”);

app.get(“/”, function(req,res){
res.sendFile(__dirname + “/views/index.html”);
res.sendFile(__dirname + “/public/style.css”);
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

Challenge: Basic Node and Express - Serve Static Assets

Link to the challenge:

The instructions say:

Mount the express.static() middleware to the path /public with app.use() . The absolute path to the assets folder is __dirname + /public .

The code you shared doesn’t do this?

Look at the examples at the bottom of the docs page.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.