Revert "move blog to /blog"

This reverts commit 4d5a3768cc.
This commit is contained in:
Lukasz Skotarek 2021-03-04 22:08:54 +01:00
parent 4d5a3768cc
commit 28aafeae39
210 changed files with 3 additions and 0 deletions

View file

@ -0,0 +1,36 @@
---
post_title: 'Today I Learned #4: Passing array/list parameters to Phoenix controller'
author: dreat
layout: post
published: true
post_date: 2020-04-10 20:00:00
tags: [til, elixir, phoenix]
categories: [til, new_blog]
---
Hello!
I had curious _incident_ while working. I was to investigate why our API won't work when passed array as url parameter for GET request.
So, I peeked into the tests and we had test for it. I logged the incoming parameters and Phoenix got an array and worked with it perfectly. So I decided to grab the big guns. Enter curl.
It was quite funny. My first insting was to create url like this:
```
some.url?param=[value1,value2]
```
but it didn't work. Phoenix read this as
```elixir
%{"param" => "[value1,value2]"}
```
and no combination of quotes would make this work.
To skip some other things I tried - the thing you need to do is to use this
```
some_url?param[]=value1&param[]=value2
```
Phoenix will read all those values as elements of an array (or, in Elixir's context, a list) and it will work as intended.