Hi, I am new to Scriptable and I wrote a script to open a webpage. Basically it first sends a POST request to get a token and cookies, then opens the webpage with the token and cookies.
let req = new Request(url)
req.method = 'POST'
req.headers = headers
req.body = body
let res = await req.loadJSON()
let token = res.token
let cookies = []
for (item of req.response.cookies) {
cookies.push(item.name + '=' + item.value)
}
req = new Request(another-url + token)
req.method = 'GET'
req.headers = { 'Cookie': cookies.join('; ') }
let wv = new WebView()
await wv.loadRequest(req)
await wv.waitForLoad()
await wv.present()
Script.complete()
When I run the script inside the app, it works fine. However, when trying to run it via shortcuts, I get an error saying Presenting a configured web view is not supported. Take a look at the static WebView.loadURL() or WebView.loadFile() instead.
The problem is it seems not able to set cookies by loadURL()
. Any solutions to solve this?