Closed zbelial closed 4 years ago
Perhaps you will like this better:
(prog1 nil
(request
"http://httpbin.org/post"
:type "POST"
:data '(("key" . "value") ("key2" . "value2"))
:sync t
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
(message "I sent: %S" (assoc-default 'form data))))))
[edit] or better yet,
(let (result)
(request
"http://httpbin.org/post"
:type "POST"
:data '(("key" . "value") ("key2" . "value2"))
:sync t
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
(setq result (format "I sent: %S" (assoc-default 'form data))))))
result)
You need to make a distinction between "stdout" and "return value". Alas, both get issued to the *Messages*
buffer.
Thank you for your reply, and sorry for that I didn't make it clear that the 'output' was actually from *Message*
.
But I have a little advice that request
's document is not very clear as it does not mention it will return something. I know that it mentions Response object
, it's not clear enough IMO.
Thanks again.
When I execute the example
it outputs
I fail to figure out why by default it outputs those following "I sent..." and how to disable it. It is really wired IMHO.