【发布时间】:2015-10-23 18:11:03
【问题描述】:
我正在尝试创建一个带有一些要设置的表单参数的 postHTTP 请求。我正在使用带有节点服务器的 axios。我已经有一个构建 url 的 java 代码实现,如下所示:
JAVA 代码:
HttpPost post = new HttpPost(UriBuilder.fromUri (getProperty("authServerUrl"))
.path(TOKEN_ACCESS_PATH).build(getProperty("realm")));
List<NameValuePair> formParams = new ArrayList<NameValuePair>();
formParams.add(new NameValuePair("username",getProperty ("username")));
formParams.add(new NameValuePair("password",getProperty ("password")));
formParams.add(new NameValuePair("client_id, "user-client"));
我正在尝试在 axios 中做同样的事情。
AXIOS 实现:
axios.post(authServerUrl +token_access_path,
{
username: 'abcd', //gave the values directly for testing
password: '1235!',
client_id: 'user-client'
}).then(function(response) {
console.log(response); //no output rendered
}
在 post 请求中设置这些表单参数的方法是否正确?
【问题讨论】:
标签: javascript node.js axios