I have an Elixir Map
:
m1 = %{a: 1, b: "fsfd", c: 123}
I want to convert it into a query string for URI
.
a=1&b=fsfd&c=123
How can I do that? I've tried this:
Enum.reduce(m1, fn({k, v}, acc) -> "#{acc}&{k}=#{v}" end)
But it didn't work, because the acc
didn't get pattern matched as intended.
You can use this:
URI.encode_query(%{a: 1, b: 2, c: "fdsfds"})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With