Загрузка...

TypeError: fetch is not a function how to solve?

Thread in Node.js created by protect Apr 8, 2022. (bumped Apr 8, 2022) 358 views

  1. protect
    [IMG]
    Code
    const response = fetch(`https://api.spotify.com/v1/search?q=${ctx.message.text}type=track`, {
    ^

    TypeError: fetch is not a function
    at C:\Users\Home\OneDrive\Рабочий стол\node\work4\bot.js:9:19
    at C:\Users\Home\OneDrive\Рабочий стол\node\work4\node_modules\telegraf\lib\composer.js:163:111
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async execute (C:\Users\Home\OneDrive\Рабочий стол\node\work4\node_modules\telegraf\lib\composer.js:468:17)
    at async C:\Users\Home\OneDrive\Рабочий стол\node\work4\node_modules\telegraf\lib\composer.js:469:21
    at async execute (C:\Users\Home\OneDrive\Рабочий стол\node\work4\node_modules\telegraf\lib\composer.js:468:17)
    at async C:\Users\Home\OneDrive\Рабочий стол\node\work4\node_modules\p-timeout\index.js:50:13
     
  2. protect
    ребят
     
  3. gcc_machine
    может дашь полный код?
    JavaScript
    const response = await fetch('https://api.spotify.com/v1/search?q=${ctx.message.text}type=track', {method: 'POST', body: 'a=1'});
    const data = await response.json();

    console.log(data);
     
  4. vtlstolyarov
    vtlstolyarov Apr 8, 2022 468 Jan 8, 2022
    JavaScript
    import fetch from 'node-fetch';
    и не забудь
    npm install node-fetch
     
Loading...
Top