Wsparcie The Movie Database

Hello, I'm creating a REST API with Node.js (I started learning Node a few days ago). The point is that when I start the server, I can make one request. From the second request onwards, I get the following error:

{
  "message": "Request error",
  "error": {
    "errno": -111,
    "code": "ECONNREFUSED",
    "syscall": "connect",
    "address": "2600:9000:2123:6c00:c:174a:c400:93a1",
    "port": 80
  }
}

My code is as follows:

import express from 'express';
import https from 'node:http';
import { moviePropsFilter } from './utils/index.mjs';

const options = {
  method: 'GET',
  hostname: 'api.themoviedb.org',
  port: null,
  path: '/3/movie/popular?language=en-US&page=1',
  headers: {
    accept: 'application/json',
    Authorization: here is my access token,
  },
};

const app = express();
app.disable('x-powered-by');

app.get('/movies/popular', (req, res) => {
  const request = https.request(options, (apiRes) => {
    let data = '';

    apiRes.on('data', (chunk) => {
      data += chunk;
    });

    apiRes.on('end', () => {
      if (apiRes.statusCode === 200) {
        res.json(moviePropsFilter(JSON.parse(data).results));
      } else {
        res.status(apiRes.statusCode).json({ error: 'An error has occurred' });
      }
      request.end();
    });
  });

  request.on('error', (err) => {
    res.status(500).json({ message: 'Request error', error: err });
    request.end();
  });
});

app.listen(1234, console.log('Listening on 1234'));

I would like to know if you can help me with this, whether it's something I'm doing wrong in the code or if it's a connection problem on my PC. Help would be appreciated.

Nie możesz znaleźć filmu lub serialu? Zaloguj się, aby go utworzyć.

Globalny

s zaznacz pasek wyszukiwania
p otwórz menu profilu
esc Zamknij otwarte okno
? otwórz okno skrótów klawiszowych

On media pages

b go back (or to parent when applicable)
e przejdź do strony edycji

On TV season pages

(prawa strzałka) przejdź do następnego sezonu
(lewa strzałka) przejdź do poprzedniego sezonu

On TV episode pages

(prawa strzałka) przejdź do następnego odcinka
(lewa strzałka) przejdź do poprzedniego odcinka

On all image pages

a otwórz okno dodawania obrazu

On all edit pages

t open translation selector
ctrl+ s prześlij formularz

On discussion pages

n otwórz nową dyskusję
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r odpowiedz na dyskusję
l przejdź do ostatniej odpowiedzi
ctrl+ enter wyślij swoją wiadomość
(prawa strzałka) następna strona
(lewa strzałka) poprzednia strona

Ustawienia

Want to rate or add this item to a list?

Zaloguj