# Server Side Swift with Vapor - Part 4: Accepting Data | Ray Wenderlich

**URL:** <https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465>\
**Category:** 🎓 Courses & Articles\
**Created:** [February 14, 2018, 5:04pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465 "2018-02-14T17:04:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [February 14, 2018, 5:04pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/1 "2018-02-14T17:04:24Z")

</div>

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](https://www.raywenderlich.com/4493-server-side-swift-with-vapor/lessons/4)

---

<div class="post-metadata">

**Author:** ![valveriy\_kliuk](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/valveriy_kliuk/32/111867_2.png) [@valveriy\_kliuk](https://forums.kodeco.com/u/valveriy_kliuk)\
**Post date:** [March 2, 2018, 7:13pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/2 "2018-03-02T19:13:44Z")

</div>

```
struct InfoData: Content {
    let name: String
}

```

> `Non-class type 'InfoData' cannot inherit from class 'Content'`

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [March 3, 2018, 1:21am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/3 "2018-03-03T01:21:30Z")

</div>

@0xtim Can you please help with this when you get a chance? Thank you - much appreciated! :]

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 3, 2018, 7:12am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/4 "2018-03-03T07:12:41Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![lashkari](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lashkari/32/81494_2.png) [@lashkari](https://forums.kodeco.com/u/lashkari)\
**Post date:** [March 3, 2018, 9:30pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/5 "2018-03-03T21:30:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lashkari](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lashkari/32/81494_2.png) [@lashkari](https://forums.kodeco.com/u/lashkari)\
**Post date:** [March 3, 2018, 9:34pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/6 "2018-03-03T21:34:43Z")

</div>

in the documentation vapor

> **[Vapor Docs](https://docs.vapor.codes/)**
>
> Vapors documentation (web framework for Swift).

i can’t find your ways to defines router (such as work with Content , or etc ) in this lesson

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 3, 2018, 9:41pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/7 "2018-03-03T21:41:35Z")

</div>

@lashkari it looks like you are on Vapor 2. Please ensure you use the `--branch=beta` flag when you create the project

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 3, 2018, 9:42pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/8 "2018-03-03T21:42:32Z")

</div>

The documentation for Vapor 3 is [https://docs.vapor.codes/3.0/](https://docs.vapor.codes/3.0/)

Note that it is quite out of date at the moment as the beta has evolved

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 3, 2018, 9:45pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/9 "2018-03-03T21:45:12Z")

</div>

@valveriy_kliuk make sure you passed in the `--branch=beta` when you created the project

---

<div class="post-metadata">

**Author:** ![lashkari](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lashkari/32/81494_2.png) [@lashkari](https://forums.kodeco.com/u/lashkari)\
**Post date:** [March 3, 2018, 9:45pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/10 "2018-03-03T21:45:55Z")

</div>

when use --branch=beta i have errors in Xcode

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 3, 2018, 9:47pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/11 "2018-03-03T21:47:06Z")

</div>

@lashkari what are the errors you are getting? Have you got Swift 4.1?

---

<div class="post-metadata">

**Author:** ![lashkari](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lashkari/32/81494_2.png) [@lashkari](https://forums.kodeco.com/u/lashkari)\
**Post date:** [March 3, 2018, 9:48pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/12 "2018-03-03T21:48:34Z")

</div>

oh sorry i don’t use this

ok, thanks download and install this now

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 3, 2018, 9:50pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/13 "2018-03-03T21:50:26Z")

</div>

No worries 🙂

Instructions for installing the Swift 4.1 toolchain are in [Video 2](https://videos.raywenderlich.com/courses/115-server-side-swift-with-vapor/lessons/2)

---

<div class="post-metadata">

**Author:** ![lashkari](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lashkari/32/81494_2.png) [@lashkari](https://forums.kodeco.com/u/lashkari)\
**Post date:** [March 3, 2018, 9:51pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/14 "2018-03-03T21:51:40Z")

</div>

Sorry  
thanks a lot 🙏

---

<div class="post-metadata">

**Author:** ![valveriy\_kliuk](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/valveriy_kliuk/32/111867_2.png) [@valveriy\_kliuk](https://forums.kodeco.com/u/valveriy_kliuk)\
**Post date:** [March 5, 2018, 2:47pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/15 "2018-03-05T14:47:34Z")

</div>

Np problem here. I have `import Vapor`

---

<div class="post-metadata">

**Author:** ![valveriy\_kliuk](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/valveriy_kliuk/32/111867_2.png) [@valveriy\_kliuk](https://forums.kodeco.com/u/valveriy_kliuk)\
**Post date:** [March 5, 2018, 2:55pm UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/16 "2018-03-05T14:55:17Z")

</div>

> [@0xtim](#):
>
> –branch=beta

I did’t passe it. Thanks!

---

<div class="post-metadata">

**Author:** ![trouge](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/trouge/32/102075_2.png) [@trouge](https://forums.kodeco.com/u/trouge)\
**Post date:** [March 22, 2018, 3:47am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/17 "2018-03-22T03:47:59Z")

</div>

The app is crashing when making the post request. “wait() must not be called when on the EventLoop” is the error. Any help?

---

<div class="post-metadata">

**Author:** ![amyerson](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@amyerson](https://forums.kodeco.com/u/amyerson)\
**Post date:** [March 22, 2018, 6:41am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/18 "2018-03-22T06:41:28Z")

</div>

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](https://drive.google.com/open?id=1C-muv2iSg8njvdOISXxFnZbpeRXm2zQv)

---

<div class="post-metadata">

**Author:** ![amyerson](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@amyerson](https://forums.kodeco.com/u/amyerson)\
**Post date:** [March 22, 2018, 6:50am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/19 "2018-03-22T06:50:58Z")

</div>

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”)  
// }

---

<div class="post-metadata">

**Author:** ![0xtim](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/0xtim/32/111111_2.png) [@0xtim](https://forums.kodeco.com/u/0xtim)\
**Post date:** [March 22, 2018, 9:05am UTC](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465/20 "2018-03-22T09:05:17Z")

</div>

@amyerson @trouge the new way of doing it is:

```swift
router.post(InfoData.self, at: "info") { req, data -> InfoResponse in
  return InfoResponse(request: data)
}

```

Apologies, originally the `wait()` call should have worked!

[Next page](https://forums.kodeco.com/t/server-side-swift-with-vapor-part-4-accepting-data-ray-wenderlich/39465.md?page=2)
