Comments (2)
Thanks for opening your first issue here! ๐ Be sure to follow the issue template!
from fiber.
You need to separate your struct field tags with a space ๐
async function handleLogin(){
const res = await fetch('/auth/login',{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"username": "john",
"password": "doe"
})
});
let body = await res.json()
console.log(body)
}
handleLogin()
package main
import "github.com/gofiber/fiber"
// User ...
type User struct {
Username string `json:"username" form:"username"`
Password string `json:"password" form:"password"`
}
func main() {
app := fiber.New()
auth := app.Group("/auth")
auth.Post("/login", func(c *fiber.Ctx) {
var user User
if err := c.BodyParser(&user); err != nil {
c.JSON(fiber.Map{
"status": "error",
"data": err.Error(),
})
} else {
c.JSON(fiber.Map{
"status": "success",
"data": user,
})
}
})
app.Listen(3000)
}
from fiber.
Related Issues (20)
- ๐ค [Question]: Custom Listen Function HOT 3
- CSRF Trusted Origins HOT 2
- ๐งน [Maintenance]: Update RFC Draft for Idempotency Middleware HOT 1
- Have I found a bug in BodyParser, or am I an idiot? HOT 4
- ๐ [Bug]: CORS middleware misclassifies all OPTIONS requests as preflight requests HOT 1
- ๐ค [Question]: Rate limit per path HOT 5
- ๐ค [Question]: How do I get default logger to log error HOT 2
- ๐ค [Question]: how to Get status code in middleware HOT 5
- ๐ [Proposal]: Add Helpers for Internal IP Ranges HOT 4
- ๐ [Bug]: version v2.52.2 up to v2.52.3 , cors error HOT 22
- ๐ [Bug]: serving a compress enabled public folder without +w permissions results in a 404 HOT 3
- ๐ *** CLOSE - I see Context( ) returns this type .... *** - r4[Proposal]: Add RequestCtx in ctx that returns *fasthttp from DefaultCtx HOT 5
- ๐ [Bug]: CORS issue HOT 2
- ๐ [Proposal]: Allow disabling cache for ctx.SendFile() HOT 2
- ๐ [Bug]: Data race on shutdown HOT 8
- ๐ค [Question]: Calling other endpoints without network HOT 7
- ๐ [Bug]: memory session store calculating expirations with uint32 HOT 3
- ๐ค [Question]: Parsing `map` in POST `form` HOT 3
- ๐งน [Maintenance]: Update docs to use a consistent indentation style HOT 4
- ๐งน [Maintenance]: Fix pushed merge-conflict in `/docs/api/middleware/earlydata.md`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiber.