دعم الموقع

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.

لم تجد الفلم أو المسلسل ؟ سجل دخولك و انشئها

عام

s ركز شريط البحث
p افتح قائمة الملف الشخصي
esc اغلق النافذة المفتوحة
? افتح نافذة اختصارات لوحة المفاتيح

على كافة صفحات الوسائط

b ارجع للخلف (او للصفحة الام عند التطبيق)
e انتقل لصفحة التعديل

على كافة صفحات موسم المسلسل

(السهم الايمن) انتقل للموسم التالي
(السهم الايسر) انتقل للموسم السابق

على كافة صفحات حلقة المسلسل

(السهم الايمن) انتقل للحلقة التالية
(السهم الايسر) انتقل للحلقة السابقة

على كافة صفحات الصور

a افتح صفحة اضافة الصورة

على كافة صفحات التعديل

t افتح محدد الترجمة
ctrl+ s ارسال النموذج

على صفحات المناقشة

n انشى نقاش جديد
w تبديل حالة المتابعة
p تبديل عام / خاص
c تبديل اغلاق / فتح
a افتح الانشطة
r رد على النقاش
l انتقل لأخر رد
ctrl+ enter أرسل رسالتك
(السهم الايمن) الصفحة التالية
(السهم الايسر) الصفحة السابقة

الاعدادات

هل تريد تقييم او اضافة هذا العنصر للقائمة؟

تسجيل الدخول