jsonvapordroplet

Why Vapor / Droplet does not receive JSON?


Sending a JSON to local service, but it does not receive it, why?

let config = try Config()
try config.setup()

let drop = try Droplet(config)
try drop.setup()

drop.get(handler: {req in

    if req.json != nil {

        print("ass")
        print(req.json!)
    }

    return "almaG"
})

enter image description here

enter image description here


Solution

  • You're sending a GET request with a body. Try sending a POST instead and use drop.post().