zsh: no matches found when $ curl -s -X localhost:60702/api/bundle?name=light%20reading | j q '.'
Asked Answered
S

3

28

I am working through the Node.js The Right Way book by Jim Wilson. I am currently trying to use a PUSH request to create a new bundle with the specified name. * curl -X POST http://:/api/bundle?name=

However, when I use the command: $ curl -s -X POST localhost:60702/api/bundle?name=light%20reading | jq '.'

rather than getting the JSON indicating that a Bundle has been created, I get: zsh: no matches found: localhost:60702/api/bundle?name=light%20reading

The command should be using a POST request to create a new All of my code is bit for bit identical to the code listed in the book. Any ideas?

Sexism answered 23/9, 2018 at 14:27 Comment(3)
what do you get when you take off everything after the pipe (the | character)Bod
Tried that, same no matches found error. Shouldn't the -X POST flag initiate a new bundle instance rather than look for an existing one?Sexism
Sorry, I am not familiar with this particular tutorial. It sounds like something going on inside the API and not a zsh related issue.Bod
S
61

Can you try

curl -s -X POST 'localhost:3000/api/bundle?name=light%20reading'

i.e wrap the url within '

Subrogate answered 15/5, 2019 at 14:32 Comment(0)
R
25

This seems to be an issue with zsh solved here.

There are several ways to solve this:

  1. You can escape the question mark ? in the url by quoting the url as explained by @huzaifa-saifuddin to avoid zsh treating it as a wildcard character.

  2. As explained here, you can create an alias for curl: alias curl='noglob curl'

  3. As explained here, you can disable to nomatch handling by adding the following to your ~/.zshrc: unsetopt nomatch

Rhyolite answered 17/9, 2020 at 5:3 Comment(1)
It's work for me. Im MacOX 12.6.2.Guendolen
O
0

Why?

You need to escape the question mark, otherwise zsh thinks it is a globbing or wildcard character and tries to find files that match it (that's why it says no matches found).

Solution: Using double or single quotescurl 'URL_ADDRESS' is enough:

curl "example.com/products?id=42" 

In your case, try this:

curl -s -X POST 'localhost:60702/api/bundle?name=light%20reading' | jq '.'
Ocam answered 7/3 at 7:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.