Skip to content

this.fetch is not a function #69

@SleeplessOne1917

Description

@SleeplessOne1917

When trying to generate an image, I get this error:

May 11 20:37:11 lemmygrad-art-bot pnpm[42126]: TypeError: this.fetch is not a function
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at Replicate.request (/home/insomnia/lemmy-art-bot/node_modules/.pnpm/[email protected]/node_modules/replicate/index.js:147:33)
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at Replicate.createPrediction (/home/insomnia/lemmy-art-bot/node_modules/.pnpm/[email protected]/node_modules/replicate/lib/pred>
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at Replicate.run (/home/insomnia/lemmy-art-bot/node_modules/.pnpm/[email protected]/node_modules/replicate/index.js:103:47)
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at generateArt (/home/insomnia/lemmy-art-bot/bot.ts:26:13)
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at Object.<anonymous> (/home/insomnia/lemmy-art-bot/bot.ts:83:29)
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at Generator.next (<anonymous>)
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at /home/insomnia/lemmy-art-bot/bot.ts:31:71
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at new Promise (<anonymous>)
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at __awaiter (/home/insomnia/lemmy-art-bot/bot.ts:27:12)
May 11 20:37:11 lemmygrad-art-bot pnpm[42126]:     at Object.mention [as handle] (/home/insomnia/lemmy-art-bot/bot.ts:78:20)

I have no idea why this is happening. I'm running on Node 18.16.0, so fetch should be defined. I also made sure that my API key is correct. Here is how I am using the library:

const replicate = new Replicate({
  auth: API_KEY,
});

const generateArt = (prompt: string) =>
  replicate.run(
    'ai-forever/kandinsky-2:601eea49d49003e6ea75a11527209c4f510a93e2112c969d548fbb45b9c4f19f',
    {
      input: {
        prompt,
        width: 768,
        height: 768,
        batch_size: 3,
      },
    }
  );

I tried passing in an option for fetch to the constructor, but it didn't show up in the typescript types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions