cdgco / dream-api

NodeJS API for Wombo Dream

Home Page:https://dream-api.cjr.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node:internal/process/promises:288

kilik128 opened this issue · comments

got this
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#".] {
code: 'ERR_UNHANDLED_REJECTION'
}

after check

// Generate image from prompt only
let image1 = await WomboDream.generateImage(1, "dog", token).catch((error) => {
// Handle the error here
console.error("Error occurred:", error);
});

it's
Error occurred: { detail: 'Invalid token' }

maybie just miss somethinks not sure like Bearer on token, ?

The UnhandledPromiseRejection is because I wasn't handling nested promise rejections in generateImage(), but that's resolved now in d43195a which I'll publish in v2.0.1. No need to add .catch() to generateImage (also if you're using the await style syntax, you would want to do a try / catch instead of .catch() anyway).

The actual error from Wombo Dream is Invalid token though, which means your API key was rejected. You shouldn't need to add Bearer or anything, the authentication should all be handled internally (bearer is already added in defineHeaders() in dream.js). Just make sure that you are setting the variable token to your API key before generateImage() like const token = "API-KEY".