Mi pregunta embarazosamente fácil es la siguiente:
¿Por qué funciona el siguiente código?
(require 'request)
(defun geocoder ()
(request
"http://rpc.geocoder.us/service/csv"
;;; **Hardcoded parameter!**
:params '(("address" . "1600 Pennsylvania Ave, Washington DC"))
:parser 'buffer-string
:success (function*
(lambda (&key data &allow-other-keys)
(when data
(with-current-buffer (get-buffer-create "*request demo*")
(erase-buffer)
(insert data)
(pop-to-buffer (current-buffer))))))
:error
(function* (lambda (&key error-thrown &allow-other-keys&rest _)
(message "Got error: %S" error-thrown)))
))
(geocoder)
Mientras que este no?
(require 'request)
(defun geocoder (address) ;; adding a parameter!
(request
"http://rpc.geocoder.us/service/csv"
:params '(("address" . address))
:parser 'buffer-string
:success (function*
(lambda (&key data &allow-other-keys)
(when data
(with-current-buffer (get-buffer-create "*request demo*")
(erase-buffer)
(insert data)
(pop-to-buffer (current-buffer))))))
:error
(function* (lambda (&key error-thrown &allow-other-keys&rest _)
(message "Got error: %S" error-thrown)))
))
;;; Now with parameter!
(geocoder "1600 Pennsylvania Ave, Washington DC")
¿Cómo debo enviar un parámetro para solicitar?
(list (cons "address" address))
si no quisieras usar backticks