-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
41 lines (33 loc) · 1.03 KB
/
script.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
let file = document.querySelector( "#file-item" )
const baseUrl = 'https://bionic-reading1.p.rapidapi.com/convert'
const readFile = async function () {
let file = document.querySelector( "#file-item" ).files[0]
if ( file.length === 0 ) {
console.log( "no file was upload" )
} else {
console.log( "we got a valid file" )
let result = await file.text()
console.log( result )
return result
}
}
const bionicRead = async function () {
let book = await readFile()
const config = {
headers: {
'content-type': 'application/x-www-form-urlencoded',
"X-RapidAPI-Key": "",
"X-RapidAPI-Host": "bionic-reading1.p.rapidapi.com"
},
data: {
"content": book,
"response_type": "page",
"request_type": "html",
"fixation": 2,
"saccade": 10
}
}
let result = await axios.post( baseUrl, config )
console.log( result )
}
file.addEventListener( "change", bionicRead )