javascriptnode.jscordovaheroku-api

Ionic cordova add platform (Error: socket hang up)


I am creating an app with ionic framework. I created an API via a cheerio scrape afterwards and connected to heroku to make a Hattp call. the problem is that while adding the android platform i get a 'socket hang up' error. How can I go about solving the problem? Thank you in advance. This is my code:

//code server (index.js) 
    const express = require("express");
    const ok = require('./srabs')
    const corsi = require('./corsiS')
    const app = express();
    const porta = '8000'
    var cors = require('cors');
    var https = require("https");
    
    
    
    app.use(cors())
    
    app.get('/', (req, res) => {
        res.send(Array(ok.Arra, corsi.cors));
    
    })
    
    
    
    app.listen(process.env.PORT || 8000, () => {
        console.log(`Server ex ${porta}`);
    });
    
    
    
    exports

    //this is cheerio srcrape n1
    
    const request = require('request');
    const cheerio = require('cheerio');
    const Arra = []
    const arra2 = []
    
    
    request('https://wwww.mywebsite.it/', (error, response, html) => {
            // reset Array on each call
    
            if (!error && response.statusCode == 200) {
                const $ = cheerio.load(html)
                const art = $('article').each((i, el) => {
                    const title = $(el)
                        .find('.entry-title.mh-posts-grid-title')
                        .text();
                    const link = $(el)
                        .find('a')
                        .attr('href');
                    const image = $(el).find('noscript').attr('data-img');
    
    
    
                    Arra.push({ title: [title], link: [link], image: [image] });
    
                });
            } 
        } 
    );
    exports.Arra = Arra;

    //this is cheerio srcrape n2
    
    const request = require('request');
    const cheerio = require('cheerio');
    const KEY_aff = '/?ffverf4fergtrrgefe12321b'
    const cors = []
    
    
    
    request('https://curses.it/courses', (error, response, html) => {
            // reset Array on each call
    
            if (!error && response.statusCode == 200) {
                const $ = cheerio.load(html);
                const art = $('.course-listing').each((i, el) => {
                    const img = $(el).find('.course-box-image-container')
                        .find('img')
                        .attr('src');
                    const link = $(el)
                        .find('a').attr('href')
    
    
                    var http = 'https://curses.it' + link + KEY_aff;
    
                    const title = $(el).find('.course-listing-title').text();
                    const subtitle = $(el).find('.course-listing-subtitle').text();
    
      cors.push({ title: [title], sub: [subtitle], linkAF: [http], img: [img] });
    
                })
            }
        }),
        exports.cors = cors;

    //this is error in terminal of ionic 
    
    Error: socket hang up
    
    at connResetException (node:internal/errors:621:14)
    at Socket.socketOnEnd (node:_http_client:502:23)
    at Socket.emit (node:events:339:22)
    at endReadableNT (node:internal/streams/readable:1289:12)
    at processTicksAndRejections (node:internal/process/task_queues:80:21)
      ionic Error: socket hang up
      ionic     at connResetException (node:internal/errors:621:14)
      ionic     at Socket.socketOnEnd (node:_http_client:502:23)
      ionic     at Socket.emit (node:events:339:22)
      ionic     at endReadableNT (node:internal/streams/readable:1289:12)
      ionic     at processTicksAndRejections (node:internal/process/task_queues:80:21) +4s

Solution

  • I solved it, it wasn't an API problem. I just re-installed the dependencies of: node.js, ionic, crodova- res.