Skip to content

Commit

Permalink
docs: node wizzard async
Browse files Browse the repository at this point in the history
  • Loading branch information
Sciator committed Oct 18, 2022
1 parent 8e08f50 commit a490282
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@ fluxQuery = \`from(bucket: "${bucket}")
|> filter(fn: (r) => r._measurement == "measurement1")
|> mean()\`
queryClient.queryRows(fluxQuery, {
next: (row, tableMeta) => {
const tableObject = tableMeta.toObject(row)
try {
for await (const {values, tableMeta} of queryClient.iterateRows(fluxQuery)) {
const tableObject = tableMeta.toObject(values)
console.log(tableObject)
},
error: (error) => {
console.error('\\nError', error)
},
complete: () => {
console.log('\\nSuccess')
},
})`
}
console.log('\\nSuccess')
} catch (error) {
console.error('\\nError', error)
}`

return (
<>
Expand Down
20 changes: 9 additions & 11 deletions src/homepageExperience/components/steps/nodejs/ExecuteQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ let fluxQuery = \`from(bucket: "${bucket}")
|> range(start: -10m)
|> filter(fn: (r) => r._measurement == "measurement1")\`
queryClient.queryRows(fluxQuery, {
next: (row, tableMeta) => {
const tableObject = tableMeta.toObject(row)
try {
for await (const {values, tableMeta} of queryClient.iterateRows(fluxQuery)) {
const tableObject = tableMeta.toObject(values)
console.log(tableObject)
},
error: (error) => {
console.error('\\nError', error)
},
complete: () => {
console.log('\\nSuccess')
},
})`
}
console.log('\\nSuccess')
} catch (error) {
console.error('\\nError', error)
}`

return (
<>
Expand Down

0 comments on commit a490282

Please sign in to comment.