Closed
Description
I know that this is more of a support issue than a bug report, but I really don't know what else to try, and didn't find another help channel.
Here is the entire script using Tokamak:
import JavaScriptKit
import TokamakDOM
struct TokamakApp: App {
var body: some Scene {
WindowGroup("Tokamak App") {
ContentView()
}
}
}
struct ContentView: View {
var body: some View {
VStack {
HTML("input", [
"id": "file",
"type": "file"
])
Button("Convert") {
let document = JSObject.global.document
let input = document.getElementById("file")
let file = input.files.item(0).object!
let promise = file.text.function!.callAsFunction().object!
JSPromise<JSValue, Error>(promise)!.then { value in
let console = JSObject.global.console.object!
let log = console.log.function!
log(value)
}
}
}
}
}
// @main attribute is not supported in SwiftPM apps.
// See https://bugs.swift.org/browse/SR-12683 for more details.
TokamakApp.main()
which is throwing this error:
Unhandled Promise Rejection: TypeError: Can only call Blob.text on instances of Blob
Running
document.getElementById("file").files.item(0).text().then(text => console.log(text))
works though.
Metadata
Assignees
Labels
No labels