jkhsjdhjs/node-fetch-cookies

ENOENT: no such file or directory, open 'jar.json'

tinamore opened this issue · 0 comments

Hi,
i have basic code

const esmImport = require('esm')(module);
const { CookieJar, fetch } = esmImport('node-fetch-cookies');
 
(async () => {
    // creates a CookieJar instance
    const cookieJar = new CookieJar("jar.json");
 
    // load cookies from the cookie jar
    await cookieJar.load();
 
    // usual fetch usage, except with one or multiple cookie jars as first parameter
    const response = await fetch(cookieJar, "https://google.com");
 
    // save the received cookies to disk
    await cookieJar.save();
})();

but when run then error:

UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'jar.json'

How do I automatically create files while saving, not need file when begin?