Hi guys,
in one of my Vapor routes I am using the following snippet:
let barcode = try req.content.get(String.self, at: "barcode")
if let code = try await Barcode.find(barcode, on: req.db) {
...
}
which works fine, provided there is a key "barcode" in the content part of the request (otherwise I get a warning)
In fact I don't remember where I got that syntax from : req.content.get( ..., at: ) , to get a single value from JSON content of a request.
Looking at docs.vapor.codes/basics/content at Single Value I would think the right syntax should be:
let barcode: String? = req.query["barcode"]
But that gives always nil. Do I miss something? Is the first syntax still admitted? If so where is it described ?
Thanks for your help !