Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question from begginer #42

Open
bubudrc opened this issue Nov 27, 2020 · 0 comments
Open

Question from begginer #42

bubudrc opened this issue Nov 27, 2020 · 0 comments

Comments

@bubudrc
Copy link

bubudrc commented Nov 27, 2020

Im followed the steps, but I have an issue and I'm dont know how to solve.

This is my struct:

//
// File.swift
//
//
// Created by Perretta, Marcelo on 10/26/20.
//

import Fluent
import Vapor
import Leaf
import SendGridKit

struct AppController {
    // MARK: Layout

    func sendContactEmail(req: Request) throws -> EventLoopFuture<Void> {
        let email = SendGridEmail(from: EmailAddress(email: "[email protected]"), replyTo: EmailAddress(email: "[email protected]"), subject: "Testing Enviroment", content: [["Nombre": "Juan Perez", "Telefono":"34234"]])
        req.application.sendgrid.initialize()
        return try req.application.sendgrid.client.send(emails: [email], on: req.eventLoop)
    }
}

and then in routes:

func routes(_ app: Application) throws {
    let appController = AppController()
    app.post("contact", use: appController.sendContactEmail)
}

but I got: Type 'Void' cannot conform to 'ResponseEncodable'; only struct/enum/class types can conform to protocols

How can I fix this?

are there any possibility to return EventLoopFuture<Void> or String from the request method?

BTW:
I'm using:

thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant