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

conform JSONObject to BodyRepresentable #1

Open
leonidas-o opened this issue Sep 5, 2017 · 0 comments
Open

conform JSONObject to BodyRepresentable #1

leonidas-o opened this issue Sep 5, 2017 · 0 comments

Comments

@leonidas-o
Copy link

Encoding MyModel to JSONObject using:

let itemJSON = try Cheetah.JSONEncoder().encode(items)

If you now would like to use itemJSON as body for vapors client:

let result = try client.put(uri: String, query: [String : NodeRepresentable], headers: [HeaderKey : String], body: BodyRepresentable?, through: [Middleware])

you would have to do do something like:

let result = try client.put(uri, ["Content-Type": "application/json"], itemJSON.makeJSON().makeBody())

as JSONObject is not conforming to BodyRepresentable, you have to call makeJSON() on the already created JSONObject

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

No branches or pull requests

1 participant