Fork me on GitHub
#cljsrn
<
2017-01-22
>
ejelome00:01:18

hey @edwthomas, finally got it working, thanks a lot guys for the hints! 😄 JS:

fetch("")
.then(function (response) {return response.json();})
.then(function (responseJSON) {return responseJSON.title;})
.then(function (result) {console.log(result)});
CLJS:
(->
 (js/fetch "")
 (.then (fn [response] (.json response)))
 (.then (fn [response-json] (:title (js->clj response-json :keywordize-keys true))))
 (.then (fn [result] (prn result))))

ejelome00:01:21

it also works without js->clj which I don't know if it makes sense (or probably only because I was logging it)

...
(.then (fn [response-json] (.-title response-json)))
...

ejelome00:01:04

... though anyways, finally I can have a good night sleep XD

pesterhazy11:01:09

@ejelome I recommend playing around with fetch in lumo, it's easier than working in a simulator

ejelome11:01:36

will look into that @peterschwarz, thanks 😄

ejelome11:01:18

btw, where do you usually play with REST, do you create a simple script or is there a place where we can play with GET/POST/PUT/DELETE etc.

vikeri11:01:40

@ejelome If you just want to test hitting an API and seeing the results in a friendly way check out Postman: https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop

pesterhazy11:01:41

I don't understand @ejelome

pesterhazy11:01:12

I usually play around with https://echo.getpostman.com/ first, from the repl

ejelome11:01:28

this is right answer, I just want to know if what I'm sending works via POST

ejelome11:01:46

oks, will try this out, thanks @pesterhazy 😄

pesterhazy11:01:16

not peterschwarz but 👍

ejelome11:01:43

ooopss, was in a hurry so I missed it XD