This commit is contained in:
anlicheng 2025-11-11 21:50:11 +08:00
parent 9e11097b25
commit 6d0110032f
2 changed files with 4 additions and 4 deletions

View File

@ -138,7 +138,7 @@ do_post(Path, Params) when is_list(Path), is_map(Params) ->
{ok, RespBody} = hackney:body(ClientRef),
lager:debug("[iot_api] request url: ~p, send body: ~p, get error is: ~p", [Url, Body, RespBody]),
hackney:close(ClientRef),
case catch jiffy:decode(RespBody) of
case catch jiffy:decode(RespBody, [return_maps]) of
#{<<"result">> := Result} ->
{ok, Result};
#{<<"error">> := #{<<"code">> := Code, <<"message">> := Message}} ->
@ -176,9 +176,9 @@ do_get(Path, Params) when is_list(Path), is_list(Params) ->
case hackney:request(get, Url, Headers, <<>>, [{pool, false}]) of
{ok, 200, _, ClientRef} ->
{ok, RespBody} = hackney:body(ClientRef),
lager:debug("[iot_api] url: ~p, get error is: ~p", [Url, RespBody]),
hackney:close(ClientRef),
case catch jiffy:decode(RespBody) of
lager:debug("[iot_api] url: ~p, get response is: ~p", [Url, RespBody]),
case catch jiffy:decode(RespBody, [return_maps]) of
#{<<"result">> := Result} ->
{ok, Result};
#{<<"error">> := #{<<"code">> := Code, <<"message">> := Message}} ->

View File

@ -25,7 +25,7 @@
{port, 18080}
]},
{api_url, "http://100.123.0.4/api/v1/"},
{api_url, "http://100.123.0.4/api/v1"},
%% 目标服务器地址
{emqx_server, [