Skip to content

Commit fa8fdba

Browse files
authored
JavaScript/TypeScript SDK: res.elements -> res (#534)
1 parent 481066c commit fa8fdba

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

api-reference/partition/examples.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Here's how you can modify partition strategy for a PDF file, and select an alter
151151
// If successfully processed, write the processed data to
152152
// the destination directory.
153153
if (res.statusCode == 200) {
154-
const jsonElements = JSON.stringify(res.elements, null, 2)
154+
const jsonElements = JSON.stringify(res, null, 2)
155155
fs.writeFileSync(outputPath + ".json", jsonElements)
156156
}
157157
}).catch((e) => {
@@ -321,7 +321,7 @@ For better OCR results, you can specify what languages your document is in using
321321
// If successfully processed, write the processed data to
322322
// the destination directory.
323323
if (res.statusCode == 200) {
324-
const jsonElements = JSON.stringify(res.elements, null, 2)
324+
const jsonElements = JSON.stringify(res, null, 2)
325325
fs.writeFileSync(outputPath + ".json", jsonElements)
326326
}
327327
}).catch((e) => {
@@ -488,7 +488,7 @@ Set the `coordinates` parameter to `true` to add this field to the elements in t
488488
// If successfully processed, write the processed data to
489489
// the destination directory.
490490
if (res.statusCode == 200) {
491-
const jsonElements = JSON.stringify(res.elements, null, 2)
491+
const jsonElements = JSON.stringify(res, null, 2)
492492
fs.writeFileSync(outputPath + ".json", jsonElements)
493493
}
494494
}).catch((e) => {
@@ -663,7 +663,7 @@ This can be helpful if you'd like to use the IDs as a primary key in a database,
663663
// If successfully processed, write the processed data to
664664
// the destination directory.
665665
if (res.statusCode == 200) {
666-
const jsonElements = JSON.stringify(res.elements, null, 2)
666+
const jsonElements = JSON.stringify(res, null, 2)
667667
fs.writeFileSync(outputPath + ".json", jsonElements)
668668
}
669669
}).catch((e) => {
@@ -839,7 +839,7 @@ By default, the `chunking_strategy` is set to `None`, and no chunking is perform
839839
// If successfully processed, write the processed data to
840840
// the destination directory.
841841
if (res.statusCode == 200) {
842-
const jsonElements = JSON.stringify(res.elements, null, 2)
842+
const jsonElements = JSON.stringify(res, null, 2)
843843
fs.writeFileSync(outputPath + ".json", jsonElements)
844844
}
845845
}).catch((e) => {

api-reference/partition/get-elements.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ The programmatic approach you take to get these document elements will depend on
9999
}).then((res) => {
100100
if (res.statusCode == 200) {
101101
// Do something with the elements, for example:
102-
saveElementsToFile(res.elements)
102+
saveElementsToFile(res)
103103
}
104104
} // ...
105105
```
@@ -124,7 +124,7 @@ The programmatic approach you take to get these document elements will depend on
124124
}
125125
}).then((res) => {
126126
if (res.statusCode == 200) {
127-
res.elements?.forEach(element => {
127+
res.forEach(element => {
128128
// Do something with each element, for example:
129129
saveElementToDatabase(`${element["element_id"]}`)
130130
saveElementToDatabase(`${element["text"]}`)
@@ -152,7 +152,7 @@ The programmatic approach you take to get these document elements will depend on
152152
}
153153
}).then((res) => {
154154
if (res.statusCode == 200) {
155-
const jsonElements = JSON.stringify(res.elements, null, 2)
155+
const jsonElements = JSON.stringify(res, null, 2)
156156

157157
fs.writeFileSync(outputFilepath, jsonElements)
158158
}

api-reference/partition/sdk-jsts.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import GetStartedSimpleAPIOnly from '/snippets/general-shared-text/get-started-s
7575
console.log(res.elements?.[0])
7676

7777
// Write the processed data to a local file.
78-
const jsonElements = JSON.stringify(res.elements, null, 2)
78+
const jsonElements = JSON.stringify(res, null, 2)
7979

8080
fs.writeFileSync("PATH_TO_OUTPUT_FILE", jsonElements)
8181
}
@@ -257,7 +257,7 @@ import GetStartedSimpleAPIOnly from '/snippets/general-shared-text/get-started-s
257257
// If successfully processed, write the processed data to
258258
// the destination directory.
259259
if (res.statusCode == 200) {
260-
const jsonElements = JSON.stringify(res.elements, null, 2)
260+
const jsonElements = JSON.stringify(res, null, 2)
261261
fs.writeFileSync(outputPath + ".json", jsonElements)
262262
}
263263
}).catch((e) => {

snippets/examples/huggingchat.ts.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ client.general.partition({
6969
if (res.statusCode == 200) {
7070
let voting_texts = ""
7171

72-
if (res.elements)
73-
for (const element of res.elements) {
72+
if (res)
73+
for (const element of res) {
7474
if (element.text.includes("vot")) {
7575
voting_texts += " " + element.text;
7676
}

0 commit comments

Comments
 (0)