CNode

用request作post请求,需要有key值重复的form表单怎么做?

Mmarsbaiyun发布于12 年前最后回复12 年前4 回复9086 浏览0 收藏

用request模拟一个请求,该请求的提交的表单如图所示:

fiddler所截取

发现提交的表单中Key值有相同的,按照之前的请求方式:

request.post({
    uri: 'xxxxxx',
    headers: {
        contentType: 'application/x-www-form-urlencoded;charset=utf-8'
    },
    form: {
        key:value,
        key: value
    }
},function(error, response, content){
    //....
});

肯定是不行的,因为form的值是个json对象,json的key值是不能重复的,那该怎么做啊?

查看回复

回复 (4)

C
chloe#1·12 年前

你可以用data

C
chloe#2·12 年前

request.post({ uri: 'xxxxxx', headers: { contentType: 'application/x-www-form-urlencoded;charset=utf-8' }, body: buffer or string },function(error, response, content){ //.... });

M
marsbaiyun#3·12 年前
引用 chloerequest.post({ uri: 'xxxxxx', headers: { contentType: 'application/x www form urlencoded;charset...

body的值是'key=value&key=value'呢还是'{key:value,key:value}'呢?

参与回复
登录后即可参与回复。登录