Lea de Groot
Lea de Groot

Reputation: 307

jq returns null from curl

I'm running the following command inside a docker container:

curl 'https://demo.cachethq.io/API/v1/components?name=Blog' | tac | tac | jq '.'

But I get null output (after the curl progress bar) Running without the final jq command gives the correct json. Any help would be appreciated (The tac is to stop the curl output ending before the jq)

Upvotes: 0

Views: 965

Answers (1)

Rao
Rao

Reputation: 21379

It is trivial error.

Please change the url from:

curl 'https://demo.cachethq.io/API/v1/components?name=Blog' | tac | tac | jq '.'

To:

curl 'https://demo.cachethq.io/api/v1/components?name=Blog' | tac | tac | jq '.'

Output:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   426    0   426    0     0    176      0 --:--:--  0:00:02 --:--:--   176
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": 20,
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 4,
      "name": "Blog",
      "description": "The Alt Three Blog.",
      "link": "https://blog.alt-three.com",
      "status": 1,
      "order": 0,
      "group_id": 2,
      "created_at": "2016-11-03 01:30:01",
      "updated_at": "2016-11-03 01:30:01",
      "deleted_at": null,
      "enabled": true,
      "status_name": "Operational",
      "tags": {
        "": ""
      }
    }
  ]
}

Upvotes: 1

Related Questions