T
T
TheBeJIIHiu2021-09-19 11:12:10
Node.js
TheBeJIIHiu, 2021-09-19 11:12:10

Why is undefined returned?

Qty:

const { AnimeWallpaper } = require("anime-wallpapers");
const wall = new AnimeWallpaper();

 function wallpaper3() {
    const wallpaper = wall.getAnimeWall3()
    gif_url = JSON.parse(wallpaper);
   console.log(gif_url.image[1])
    
}


wallpaper3()


Returns:
Auto installing libraries...
Auto installation complete.
+ node index.js
undefined:1
[object Promise]
 ^

SyntaxError: Unexpected token o in JSON at position 1
    at JSON.parse (<anonymous>)
    at wallpaper3 (/home/dcoder/anime/index.js:6:20)
    at Object.<anonymous> (/home/dcoder/anime/index.js:12:1)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47


And I need to return the link to the photo, help me fix it. There are many links but you only need to get one.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Slava Rozhnev, 2021-09-19
@rozhnev

At least take a look at the documentation :
6146f355355fc159171058.png

L
low molecular macro, 2021-09-19
@molekulyarniy

Read the documentation. Here, in theory, an asynchronous call
const wallpaper =

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question