跳到主要内容
CNode

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

社区
Mmarsbaiyun发布于 12 年前最后回复 12 年前
490950

用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)

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

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

C
chloe#212 年前

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

C
chloe#112 年前

你可以用data

参与回复

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