You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to pass any object to a view via render function, I get the error: "Leaf/LeafEncoder.swift:162: Fatal error."
In this example, I pull a list of cocktails from the database, put them into context and try to pass them to the view:
app.get("dashboard")` { req async throws -> View in
let result = try await Cocktail.query(on: req.db).all()
let context = CocktailContext(cocktails: result)
return try await req.view.render("dashboard", context)
}
Here is my Context Struct:
struct CocktailContext: Codable, Content {
let cocktails: [Cocktail]
}
Here is my Cocktail Model:
import Fluent
import Vapor
final class Cocktail: Model, Content, Codable {
static let schema = "cocktail"
@ID(key: .id)
var id: UUID?
@Field(key: "name")
var name: String
@Field(key: "description")
var description: String
@Field(key: "amount_ml")
var amount_ml: Int
@Field(key: "img_url")
var img_url: String
@OptionalField(key: "video_url")
var video_url: String?
@Parent(key: "difficulty_id")
var difficulty_id: Difficulty
@Parent(key: "glass_id")
var glass_id: Glass
}
This happens not only with the database output but also when I try to create a cocktail object directly, for example. Or with other Object:
Even if it is deliberate behavior, there is no information about what the error is! I mean, I may make a mistake, but since the application throws a fatal error without description at this point, I have no idea how to deal with it.
I use Vapor 4.65.0 and Leaf 4.2.0 on MacOS Monterey
Kind regards
Jannik
The text was updated successfully, but these errors were encountered:
Hi together,
When I try to pass any object to a view via render function, I get the error: "Leaf/LeafEncoder.swift:162: Fatal error."
In this example, I pull a list of cocktails from the database, put them into context and try to pass them to the view:
Here is my Context Struct:
Here is my Cocktail Model:
This happens not only with the database output but also when I try to create a cocktail object directly, for example. Or with other Object:
return try await req.view.render("dashboard", Difficulty(id: UUID(), difficulty: "med"))
Even if it is deliberate behavior, there is no information about what the error is! I mean, I may make a mistake, but since the application throws a fatal error without description at this point, I have no idea how to deal with it.
I use Vapor 4.65.0 and Leaf 4.2.0 on MacOS Monterey
Kind regards
Jannik
The text was updated successfully, but these errors were encountered: