In this video, you'll learn how to accept data in your Vapor applications and parse it with Codable.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4493-server-side-swift-with-vapor/lessons/4
In this video, you'll learn how to accept data in your Vapor applications and parse it with Codable.
struct InfoData: Content {
let name: String
}
Non-class type 'InfoData' cannot inherit from class 'Content'
@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]
@valveriy_kliuk have you got a class called Content
declared anywhere? If you click through to the definition in Xcode where does it think itâs declared? Also check that you have import Vapor
in the file
hello , can you help me? please
when definition struct
i have this error
struct InfoResponse : Content {
let name : String
}
First Error : Non-class type âInfoResponseâ cannot inherit from class âContentâ
and when definition return value " req â InfoResponse "
i have this error
Second Error : Unable to infer closure type in the current context
in the documentation vapor
i canât find your ways to defines router (such as work with Content , or etc ) in this lesson
@lashkari it looks like you are on Vapor 2. Please ensure you use the --branch=beta
flag when you create the project
The documentation for Vapor 3 is https://docs.vapor.codes/3.0/
Note that it is quite out of date at the moment as the beta has evolved
@valveriy_kliuk make sure you passed in the --branch=beta
when you created the project
when use --branch=beta i have errors in Xcode
@lashkari what are the errors you are getting? Have you got Swift 4.1?
oh sorry i donât use this
ok, thanks download and install this now
No worries
Instructions for installing the Swift 4.1 toolchain are in Video 2
Sorry
thanks a lot
Np problem here. I have import Vapor
I didât passe it. Thanks!
The app is crashing when making the post request. âwait() must not be called when on the EventLoopâ is the error. Any help?
I think this is an NIO issue. I guess it was just implemented into Vapor today or yesterday, and it includes a precondition against this. Not sure if it has to do with the deprecation of await too? I got errors when trying to use wait () instead of await(). Using up-to-date/beta versions of everything: Swift 4.1, Xcode 9.3 beta4 , and Vapor 3.1.4.l --see 1 minute video for the errors: https://drive.google.com/open?id=1C-muv2iSg8njvdOISXxFnZbpeRXm2zQv
I got it to work by commenting out this precondition in the EventLoopFuture.swift file (temporarily for the exercise only of course):
// if !(self.eventLoop is EmbeddedEventLoop) {
// precondition(!eventLoop.inEventLoop, âwait() must not be called when on the EventLoopâ)
// }