```HtmlContent { head { title { +"Posts" }...
# ktor
g
Copy code
HtmlContent {
        head { title { +"Posts" } }
}
Here you are effectively calling the constructor of HtmlContent and adding content to it, but you are not returning the constructed instance. Your function
respondWithPostList
has no return type, so it will implicitly return
Unit
. I think the most neat solution is to make your
respondWithPostList
function an extension method of
HtmlContent
. So it would look like this:
Copy code
fun HtmlContent.respondWithPostList(posts: List<PostDTO>?) {
        head { title { +"Posts" } }
        body {
            posts?.forEach { post ->
                run {
                    div {
                        h3 {+"${post.title} (${post.id})"}
                        p {+post.author.email}
                    }
                }
            }
        }
}
h
Thanks a lot Gerard for the reply. But for the first mistake I made the following should work, shouldn't it?
g
Yeah, I think that works too.
👍 1
Theoretically at least, I can't really test it right now 😉
h
Yeees, thanks a lot buddy