I do my best to listen to, be mindful of, and learn from those around me. I enjoy programming and the thinking that goes along with it. I enjoy contributing and collaborating.
When I start the server and make a request to the home page, these are the results:
The server has started and is listening on port number: 3000
Request url: /
Time:1580704003783
Path to index view:
C:\Users\Daniel\Documents\TypeScript\serve_html\views\index.html
Request url: /favicon.ico
Time:1580704004292
Path to index view:
C:\Users\Daniel\Documents\TypeScript\serve_html\favicon.ico
The path to the index view is changing with each request.
Additionally, if I try to have my 404 page appear,
I receive the following,
Request url: /error
Time:1580704087558
Path to index view:
undefined
When the path to the index changes, it attempts to find something that isn't there and becomes undefined.
I feel that I'm a lot closer than I was before. I'll keep logging and stepping through to see what's causing this.
I do my best to listen to, be mindful of, and learn from those around me. I enjoy programming and the thinking that goes along with it. I enjoy contributing and collaborating.
Very good call on adding the additional
console.log
's!I changed my server code to no longer use
res.end()
asI learned that this is automatically taken care of by the
.pipe()
method.The server looks like this now:
When I start the server and make a request to the home page, these are the results:
The path to the index view is changing with each request.
Additionally, if I try to have my 404 page appear,
I receive the following,
When the path to the index changes, it attempts to find something that isn't there and becomes
undefined
.I feel that I'm a lot closer than I was before. I'll keep logging and stepping through to see what's causing this.
Two things:
if (sendToErrorPage)
block sosendToErrorPage
is not set totrue
.createReadStream
be wrapped in anelse
? It's only supposed to be called when the path is correct, right?Wrapping the second
createReadStream
inside anelse
got everything working.For good measure, I added the
favicon
tags in both HTML<head>
tags.Thank you so much for your help!! 🎉🎉