You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -116,7 +114,7 @@ open urls.json | get urls | each { |u| http get $u -r }
116
114
To combine these responses together into a valid JSON array, you can turn the table into json.
117
115
118
116
```nu
119
-
open urls.json | get urls | each { |u| http get $u } | to json
117
+
open urls.json | each { |u| http get $u } | to json
120
118
```
121
119
122
120
Output
@@ -150,16 +148,14 @@ Making a `post` request to an endpoint with a JSON payload. To make long request
150
148
151
149
```json
152
150
{
153
-
"my_payload": {
154
-
"title": "foo",
155
-
"body": "bar",
156
-
"userId": 1
157
-
}
151
+
"title": "foo",
152
+
"body": "bar",
153
+
"userId": 1
158
154
}
159
155
```
160
156
161
157
```nu
162
-
open payload.json | get my_payload | to json | http post https://jsonplaceholder.typicode.com/posts $in
158
+
open payload.json | to json | http post https://jsonplaceholder.typicode.com/posts $in
163
159
# => ━━━━━
164
160
# => id
165
161
# => ─────
@@ -172,7 +168,7 @@ open payload.json | get my_payload | to json | http post https://jsonplaceholder
172
168
We can put this all together into a pipeline where we read data, manipulate it, and then send it back to the API. Lets `fetch` a post, `increment` the id, and `post` it back to the endpoint. In this particular example, the test endpoint gives back an arbitrary response which we can't actually mutate.
173
169
174
170
```nu
175
-
open urls.json | get urls | first | http get $in | upsert id {|item| $item.id | inc} | to json | http post https://jsonplaceholder.typicode.com/posts $in
171
+
open urls.json | first | http get $in | upsert id {|item| $item.id | inc} | to json | http post https://jsonplaceholder.typicode.com/posts $in
0 commit comments