We'll learn how we can use the EdgeJS Template Engine to render HTML views and send them back as the response for our routes. We'll also see how we can pass dynamic data into our views from our route handler.
Agreed, and thank you for the suggestion! It'd be good to cover those things, and we will most certainly get to them! It won't be within this series though, as we want this series to be a good entry point for everyone coming to AdonisJS 6, and using EdgeJS is the most inclusive way to do that as it's a part of the framework.
We'll plan and add series for these into our schedule!
Thanks Tom. I imagine you also will be updating a lot of your v5 lessons to v6. I really like your style. I find you way easier to understand than most tutorialists
Yeah, I've got quite a bit planned including additional focus on project-based series that'll cover updated topics we covered in v5! I'll be putting 100% of my focus on this series until we wrap it up, then we'll move onward from there 😄
Hi Tom, can you tell me why when I inspect the request object the parsed url host, protocol, etc are always null? I'm not sure the difference between host and hostname (if they were not null I could figure it out haha), but I want to be able to key off of that value in my code. I could grab the host header and parse that, but I'd rather just use the parsedUrl property for everything.
It looks like AdonisJS is using the request.url to parse these details out using the parse method from node:url and it looks like the request.url only contains the path for the request. So, it's being built without those details included and since the parsedUrl object is just an instance of URL that'd be why they're still included despite being null.
router.get('/my-endpoint', (ctx) => { // passing true to completeUrl will include the query string const completeUrl = new URL(ctx.request.completeUrl(true)) return completeUrl})
Copied!
Host and hostname will mostly be the same. The difference is, if the URL contains a port, host will include it and hostname will not.
Thanks! I followed the link to the source code and it looks like all I have to do to get what I want is request.hostname(), and that method just pulls the info out of the headers anyway.