The Movie Database Support

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.

Can't find a movie or TV show? Login to create it.

Global

s focus the search bar
p open profile menu
esc close an open window
? open keyboard shortcut window

On media pages

b go back (or to parent when applicable)
e go to edit page

On TV season pages

(right arrow) go to next season
(left arrow) go to previous season

On TV episode pages

(right arrow) go to next episode
(left arrow) go to previous episode

On all image pages

a open add image window

On all edit pages

t open translation selector
ctrl+ s submit form

On discussion pages

n create new discussion
w toggle watching status
p toggle public/private
c toggle close/open
a open activity
r reply to discussion
l go to last reply
ctrl+ enter submit your message
(right arrow) next page
(left arrow) previous page

Settings

Want to rate or add this item to a list?

Logg inn