I'm really new to elixir, so forgive my ignorance. I have a json response in body
(coming from a public api) that i need to decode twice to actually get a map that i can pattern match. I do not understand why is that happening and how to avoid it? Thanks.
body = "\"{\\\"access_token\\\":\\\"r5f3w73pjjjoembe4azhp892475wah\\\",\\\"expires_in\\\":5102694,\\\"token_type\\\":\\\"bearer\\\"}\\n\""
result = body |> Jason.decode! |> Jason.decode!
%{"access_token" => access_token} = result
Edit: The response is alright in Postman/Node fetch, it's just escaped like that when it's coming from the Tesla client in elixir.