8000 Expecting type `String` for html parameter, getting `Future<View>` · Issue #26 · vapor-community/mailgun · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Expecting type String for html parameter, getting Future<View> #26
Open
@nickfarrant

Description

@nickfarrant

Hi,

Great library, works really well.

The only issue I am having is using a Leaf template. The example code in the readme is generating an error in Xcode for me.

router.post("mail") { (req) -> Future<Response> in
    let content = try req.view().render("Emails/my-email", [
        "name": "Bob"
    ])

    let message = Mailgun.Message(
        from: "postmaster@example.com",
        to: "example@gmail.com",
        subject: "Newsletter",
        text: "",
        html: content
    )

    let mailgun = try req.make(Mailgun.self)
    return try mailgun.send(message, on: req)
}

content is of type Future<View>, but Mailgun.Message expect a String for the html parameter.

Is there a way around this or am I missing something obvious?

I have tried html: "\(content)", but my Leaf template then generates: NIO.EventLoopFuture in the email.

Thanks in advance,
Nick

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0