fix: json linting not working on raw body + small ts corrections
This commit is contained in:
19
packages/hoppscotch-app/helpers/functional/files.ts
Normal file
19
packages/hoppscotch-app/helpers/functional/files.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import * as TO from "fp-ts/TaskOption"
|
||||
|
||||
export const readFileAsText = (file: File) =>
|
||||
TO.tryCatch(
|
||||
() =>
|
||||
new Promise<string>((resolve, reject) => {
|
||||
const reader = new FileReader()
|
||||
|
||||
reader.onload = () => {
|
||||
resolve(reader.result as string)
|
||||
}
|
||||
|
||||
reader.onerror = () => {
|
||||
reject(new Error("File err"))
|
||||
}
|
||||
|
||||
reader.readAsText(file)
|
||||
})
|
||||
)
|
||||
Reference in New Issue
Block a user