Skip to content

Instantly share code, notes, and snippets.

@deadghost
Created January 15, 2018 23:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save deadghost/b86059528804f36dca8592df06ea91f1 to your computer and use it in GitHub Desktop.
(reg-event-fx
:http/delete-contact!
(fn [{:keys [db]} [_ id]]
{:http-xhrio {:method :delete
:uri (str api-url "contacts/" id)
:timeout 5000
:format (ajax/json-request-format)
:response-format (ajax/json-response-format)
:on-success [:http/delete-contact!--success id]
:on-failure [:http/set-error]}}))
(reg-event-db
:http/set-error
(fn [db [_ error]]
(assoc-in db ["state" "error"] error)))
;; This gets run but db is always empty. This is confirmed with (.log js/console (str db)).
;; Any assocs will assoc to nil. Is there anything obviously wrong that would cause this?
;; Response that triggers this is 204 No Content. db just doesn't seem to get passed in.
(reg-event-db
:http/delete-contact!--success
(fn [db [_ id]]
db))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment