[Postman] Send an array as form-data
[Postman] Send an array as form-data
💭 What is Postman?
- 🧐 Postman is an application used for API testing. You can test various types of HTTP requests (POST, GET, PUT, PATCH, DELETE) . Please refer to Postman official website for more details.
1. Send an array as form-data in Postman
- Suffix your variable’s name with squared brackets [ ]
- ex) array[index]
Key | Value |
---|---|
score[0] | 10 |
score[1] | 7 |
score[2] | 8 |
Check the data packet by 📋 < Node.js code >
console.log(req.body.score);
📋 < Result >
[10, 7, 8]
2. Send an array of dictionaries as form-data
- ex) array[index][key]
Key | Value |
---|---|
score[0][math] | 98 |
score[0][physics] | 78 |
score[0][chemistry] | 89 |
score[1][math] | 72 |
score[1][physics] | 30 |
score[1][chemistry] | 90 |
📋 < Result >
"score": [
{
"math": 98,
"physics": 78,
"chemistry": 89,
},
{
"math": 72,
"physics": 30,
"chemistry": 90,
}
]
Reference: