Skip to content

Commit c59548c

Browse files
committed
fetchData API get result conversion processing
1 parent f9ff12f commit c59548c

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default class XCrawl {
6666
const container: IFetchData<T> = []
6767

6868
await batchRequest(requestConfigQueue, intervalTime, (requestRes) => {
69-
const data: T = JSON.parse(requestRes.data.toString())
69+
const data: T = JSON.parse(JSON.stringify(requestRes.data.toString()))
7070
container.push({ ...requestRes, data })
7171
})
7272

test/start/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/start/index.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
import XCrawl from '../../src'
22

3-
const githubDocsXCrawl = new XCrawl({
3+
const testXCrawl = new XCrawl({
4+
baseUrl: 'http://localhost:9001/api',
45
timeout: 10000,
56
intervalTime: {
67
max: 3000,
78
min: 1000
89
}
910
})
1011

11-
githubDocsXCrawl.fetchHTML('https://docs.github.com/zh').then((jsdom) => {
12-
console.log(jsdom.window.document.querySelector('title')?.textContent)
13-
})
12+
testXCrawl
13+
.fetchData({
14+
requestConifg: {
15+
url: '/home/goodprice',
16+
method: 'POST'
17+
}
18+
})
19+
.then((res) => {
20+
console.log(res)
21+
})

0 commit comments

Comments
 (0)