Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix code snippet(headers) of Multipart in README.md #472

Merged
merged 1 commit into from Apr 3, 2023

Conversation

TORIFUKUKaiou
Copy link
Contributor

Nice to meet you.
Thank you very much for the greatest http client project.

I found a bit mistake snippet in README.md .
It is ### Multipart part.

iex> token = "some_token_from_another_request"
iex> headers = ["Authorization": "Bearer #{token}", {"Content-Type", "multipart/form-data"}]
** (SyntaxError) iex:2:46: unexpected expression after keyword list. Keyword lists must always come last in lists and maps. Therefore, this is not allowed:

    [some: :value, :another]
    %{some: :value, another => value}

Instead, reorder it to be the last entry:

    [:another, some: :value]
    %{another => value, some: :value}

Syntax error after: ','
    |
  2 | headers = ["Authorization": "Bearer #{token}", {"Content-Type", "multipart/form-data"}]
    |                                              ^
    (iex 1.14.3) lib/iex/evaluator.ex:292: IEx.Evaluator.parse_eval_inspect/3
    (iex 1.14.3) lib/iex/evaluator.ex:187: IEx.Evaluator.loop/1
    (iex 1.14.3) lib/iex/evaluator.ex:32: IEx.Evaluator.init/4
    (stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

I fixed it.

Hope this helps.

README.md Outdated
@@ -292,7 +292,7 @@ can do the below:
```elixir
binary_file_content = "Something you fetched and now have it in memory"
token = "some_token_from_another_request"
headers = ["Authorization": "Bearer #{token}", {"Content-Type", "multipart/form-data"}]
headers = [Authorization: "Bearer #{token}", "Content-Type": "multipart/form-data"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best solution here is to use tuples with strings instead of atoms 🤔 . I'm assuming this was the original intention

[{"Authorization, "Bearer #{token}"}, {"Content-type", "multipart/form-data"}]

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your review.
Error message has a keyword list.

unexpected expression after keyword list. Keyword lists must always come last in lists and maps. Therefore, this is not allowed:

So I assume a keyword list.

I updated to use tupples.

@edgurgel edgurgel merged commit b06c7b4 into edgurgel:main Apr 3, 2023
2 checks passed
@edgurgel
Copy link
Owner

edgurgel commented Apr 3, 2023

Thank you! 🎉

@TORIFUKUKaiou TORIFUKUKaiou deleted the fix/README branch April 3, 2023 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants