JSONP
Sends a JSON response with JSONP support. This method is identical to JSON, except that it opts-in to JSONP callback support. By default, the callback name is simply callback.
Override this by passing a named string in the method.
c.JSONP(v interface{}, callback ...string) error
type SomeStruct struct {
name string
age uint8
}
app.Get("/", func(c *fiber.Ctx) {
// Create data struct:
data := SomeStruct{
name: "Grame",
age: 20,
}
c.JSONP(data)
// => callback({"name": "Grame", "age": 20})
c.JSONP(data, "customFunc")
// => customFunc({"name": "Grame", "age": 20})
})