3

I'm building an API, I can't figure out how to return an empty response if most of them are like:

func GetEntityInstance(c *fiber.Ctx) error {

    ...

    return c.Status(fiber.StatusCreated).JSON(fiber.Map{
        "id_created": new_id,
    })
}

How can I send an empty body response?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
hestellezg
  • 3,309
  • 3
  • 33
  • 37

1 Answers1

5

As simple as it gets:

func main() {
    app := fiber.New()

    app.Get("/", func(c *fiber.Ctx) error {
        return c.Send(nil)
    })

    app.Listen(":5000")
}

You can aslo do return c.SendStatus(http.StatusAccepted)

advay rajhansa
  • 1,129
  • 9
  • 17