0

My Discord bot continuously sends [Object Promised] when I use

const DabiImages = require("dabi-images");
const DabiClient = new DabiImages.Client();
DabiClient.sfw.real.random().then(json => {
    console.log(json);
 }).catch(error => {
    console.log(error);
 });

I was wondering how I can fix this, as I'm not sure.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • I think I saw the answer to this recently. Your DabiClient returns a promise, and when that is resolved it returns a JSON object, which itself is a promise. That needs to be resolved too, presumably also with a `.then()`. – halfer Apr 13 '20 at 09:51
  • Maybe this is the answer? https://stackoverflow.com/a/37555432 – halfer Apr 13 '20 at 09:53

1 Answers1

0

I think the comments on this already answer the question but you could..

const DabiImages = require('dabi-images')

const DabiClient = new DabiImages.Client()

const main = async () => {
    const dabiJson = await DabiClient.sfw.real.random()
    console.log(dabiJson)
}

main()

Also worth mentioning, that the sfw doesn't exist

razki
  • 1,171
  • 2
  • 8
  • 16