Skip to content

Adding POST and GET examples #828

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

zamderax
Copy link

  1. Adding POST and GET examples
  2. Adding easy examples for Codable, GET and POST to the Readme

import NIOCore
import NIOFoundationCompat

struct Comic: Codable{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct Comic: Codable{
struct Comic: Codable {


static func getJSON() async throws {
let httpClient = HTTPClient(eventLoopGroupProvider: .singleton)
let car: Car = Car(make: "Toyota", model: "Camry", year: 2023)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This object is unused, and so this code snippet won't compile.

request.headers.add(name: "Accept", value: "application/json")
request.method = .POST
request.body = .bytes(jsonData)
try await httpClient.shutdown()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example doesn't send the request at all.

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

Successfully merging this pull request may close these issues.

2 participants