Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upPosting Arrays in Form #1538
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
froatsnook
Apr 10, 2015
Contributor
Since form in your example is a regular javascript object, you can't have two of the same key. Instead you should make amounts itself an array, like:
request({
method: 'POST',
url: '...',
form: {
'amounts': [14, 26]
}
})That will make amounts[0]=41&amounts[1]=26. If you need amounts[]=41&amounts[]=26, then use qsStringifyOptions like so:
request({
method: 'POST',
url: '...',
form: {
'amounts': [14, 26]
},
qsStringifyOptions: { arrayFormat: 'brackets' }
})|
Since request({
method: 'POST',
url: '...',
form: {
'amounts': [14, 26]
}
})That will make request({
method: 'POST',
url: '...',
form: {
'amounts': [14, 26]
},
qsStringifyOptions: { arrayFormat: 'brackets' }
}) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pon
Apr 10, 2015
Thanks! I misread the documentation - I thought that only applied to the query string
pon
commented
Apr 10, 2015
|
Thanks! I misread the documentation - I thought that only applied to the query string |
pon commentedApr 10, 2015
I am attempting to consume an API and am unable to make the following request:
curl https://api.stripe.com/v1/customers/{id}/bank_accounts/{id}/verify \ -d amounts[]=14 \ -d amounts[]=26The below code doesn't work because having two keys of the same name the second overwrites the first. Is this type of request supported here?