我想在我的erlang程序中调用httprc:request
,但我得到一个异常,它没有任何信息给我,出了什么问题。
这是我的代码:
print_helloworld() ->
Body = "userId=12345",
httpc:request(post,
{
"'http://192.168.2.100:8080/010/xmppcontrol", [],
"application/x-www-form-urlencoded",
Body
}, [], []).
这是我的例外:
1> hello_world:print_helloworld().
** exception exit: {noproc,
{gen_server,call,
[httpc_manager,
{request,
{request,undefined,<0.58.0>,0,'\'http',
{"192.168.2.100",8080},
"/010/xmppcontrol",[],post,
{http_request_h,undefined,"keep-alive",undefined,
undefined,undefined,undefined,undefined,undefined,
undefined,...},
{"application/x-www-form-urlencoded","userId=12345"},
{http_options,"HTTP/1.1",infinity,true,
{essl,[]},
undefined,false,infinity,...},
"'http://192.168.2.100:8080/010/xmppcontrol",[],none,
[],1510504662776,undefined,undefined,false}},
infinity]}}
in function gen_server:call/3 (gen_server.erl, line 214)
in call from httpc:handle_request/9 (httpc.erl, line 554)
你能说出httpc:request
调用中的错误,因为当我从JS调用URL时,它运行正常。
这是我的JavaScript代码:
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
asyncRequest = new XMLHttpRequest();
asyncRequest.addEventListener("readystatechange", stateChange, false);
asyncRequest.open('POST', 'http://192.168.2.100:8080/010/xmppcontrol?userId=' + userId , true);
asyncRequest.send(null);
提前致谢。