-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathaxios-node.js
45 lines (40 loc) · 898 Bytes
/
axios-node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import axios from 'axios'
import fs from 'fs'
const PORT = 5000
// const PORT = 8080
const service = axios.create({
baseURL: `http://localhost:${ PORT }`
})
const init = () => {
service.post('/combine-pdf', {
pdfList: [
{
url: 'https://www.baidu.com/',
isLandscape: true,
attachment: {
header: 'Header 自定义页眉',
footer: 'Footer 自定义页脚'
}
},
{
url: 'https://zh-hans.reactjs.org/',
// hasMargin: false,
isLandscape: true,
cookies: [
{
name: 'token',
value: 'fc83532c-f833-11eb-8526-0242ac130002',
domain: 'localhost'
}
]
}
]
}, {
responseType: 'arraybuffer'
}).then((res) => {
fs.writeFileSync('combime-test1.pdf', res.data)
}).catch((err) => {
console.log(err)
})
}
init()