evaluate
Evaluates JavaScript client-side, via raw content or a URL to some JavaScript code, in the browser's page environment
**Usage Example:**
mutation EvaluateScript {
byContent: evaluate(content: "2 + 2") {
value
}
byUrl: evaluate(url: "https://example.com/script.js") {
value
}
}
**Field Definition:**
evaluate(
content: String
timeout: Float
url: String
): EvaluateResponse
Arguments
evaluate.content ● String scalar
The raw script you'd like to evaluate. This code gets wrapped in an async function so you can use return at the end as well as await and other async concepts. You can return any stringified value from this function
evaluate.timeout ● Float scalar
A timeout to wait for the script to finish evaluating, overriding any defaults. Useful for async scripts that may be longer running. Defaults to the session's default timeout: 30 seconds (30000) unless changed with the preferences mutation. Pass 0 for no limit; negative values are rejected. A script that runs longer fails with a "timed out" error. A script still running synchronously (for example a busy loop) is stopped; work it has already scheduled, such as timers or pending promises, keeps running in the page. With url, a positive limit also covers downloading the script; otherwise the download is limited to 10 seconds.
evaluate.url ● String scalar
The URL of the script you'd like to evaluate. This code gets wrapped in an async function so you can use return at the end as well as await and other async
concepts. You can return any stringified value from this function
Type
EvaluateResponse object
Response returned after evaluating a script