I know how to use request.el to get data and insert it into a buffer, but what if I want to simply have request.el return the data itself (e.g., for saving in a variable)?
Here's my attempt, but this doesn't actually return data (in this case a small amount of test JSON):
(request "https://jsonplaceholder.typicode.com/todos/1"
:parser 'json-read
:success (cl-function
(lambda (&key data &allow-other-keys)
data))))
(let* ((buf (url-retrieve-synchronously "https://api.github.com/users/lawlist/gists")) (str (with-current-buffer buf (buffer-string)))) (kill-buffer buf) str)
parser
states in part: "So, for example, you can passjson-read
to parse JSON object in the buffer. To fetch whole response as a string, passbuffer-string
." Have a look at the doc-string for other clues and perhaps try usingbuffer-string
as suggested ... I don't have that particular library installed at the moment, and merely git cloned it to see what makes it tick ... github.com/tkf/emacs-request/blob/master/request.el#L439