[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A (probably silly) problem with request.el
From: |
Marcin Borkowski |
Subject: |
Re: A (probably silly) problem with request.el |
Date: |
Sat, 06 Jun 2015 22:44:16 +0200 |
On 2015-06-06, at 21:25, Nicolas Richard <youngfrog@members.fsf.org> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>> Now the question is:
>> how do I do anything reasonable with what I got? In my particular case
>> I expect json, so I'd like to use e.g. json.el to convert it to s-exps.
>> How do I do that? I tried
>>
>> (request "http://httpbin.org/get" :parser #'json-read),
>
> The request form will *never*[1] return json, because it returns before the
> request is complete. This is what asynchronous means, and that is why I
> said "The real job must be done by a callback function".
>
> The very first example in the homepage of the package uses httpbin.org.
> Here's a simplified version of it :
>
> (request
> "http://httpbin.org/get"
> :parser 'json-read
> :success (function*
> (lambda (&key data &allow-other-keys)
> (message "response: %S" data))))
>
> Please try it and see what happens. The function mentionned as :success
> takes over once the request is complete (well, unless the request fails
> obviously...). That is a "callback" function.
OK, so now that I played with it for a moment, let me ask more questions
(not very urgent ones, I'm just curious). Do I get it correctly that
the "success" function will be called *at some later point* (assuming
that the request succeeded)? What Emacs mechanism is used for that -
timers? (I assume that the asynchronicity is more or less natural when
using curl, and then async processes are used, right? Does url.el also
use some external tool?)
TIA,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
- A (probably silly) problem with request.el, Marcin Borkowski, 2015/06/04
- Re: A (probably silly) problem with request.el, Nicolas Richard, 2015/06/05
- Re: A (probably silly) problem with request.el, Marcin Borkowski, 2015/06/05
- Re: A (probably silly) problem with request.el, Nicolas Richard, 2015/06/05
- Re: A (probably silly) problem with request.el, Marcin Borkowski, 2015/06/05
- Re: A (probably silly) problem with request.el, Nicolas Richard, 2015/06/06
- Re: A (probably silly) problem with request.el, Marcin Borkowski, 2015/06/06
- Re: A (probably silly) problem with request.el,
Marcin Borkowski <=
- Re: A (probably silly) problem with request.el, Nicolas Richard, 2015/06/08
- Re: A (probably silly) problem with request.el, Marcin Borkowski, 2015/06/10
- Re: A (probably silly) problem with request.el, John Mastro, 2015/06/10