Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

How do I use fs in JsFunction #175

Open
ivanfjz opened this issue Apr 11, 2022 · 0 comments
Open

How do I use fs in JsFunction #175

ivanfjz opened this issue Apr 11, 2022 · 0 comments

Comments

@ivanfjz
Copy link

ivanfjz commented Apr 11, 2022

This is my codes:

$page->on('response', JsFunction::createWithParameters(['response','fs'])->body("
                if(response.url().indexOf('img.xxxx.com') > -1){
                    let responseUrl = response.url();
                    const imgbuffer = await response.buffer();
                    fs.writeFileSync(img_path, imgbuffer);
                }
            ")->async(true)->scope(['img_path' => $img_path]));

it alert fs is undefined

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant