Chapter 7 - Type of expression is ambiguous without more context - Unable to build

I’m thrown an expression error of “Type of expression is ambiguous without more context” on the line expressing the return when running this router code.

// Search
    router.get("API", "acronyms", "search") { req -> Future<Acronym> in
        guard
            let searchTerm = req.query[String.self, at: "term"] else {
                throw Abort(.badRequest)
        }
        return Acronym.query(on: req)
        .filter(.short == searchTerm)
        .all()
    }

02%20AM

Anyone know why I am getting this error?

Update:

I was missing Import Fluent.

1 Like

@rniller Glad you fixed it! :]

Lol rookie mistake on my part :stuck_out_tongue: Btw, this book is amazing! I’m so glad I stumbled upon it.

2 Likes