Ionic cordova add platform (Error: socket hang up)
Ionic cordova add platform (Error: socket hang up)
我正在使用离子框架创建一个应用程序。之后我通过 cheerio scrape 创建了一个 API 并连接到 heroku 进行 Hattp 调用。问题是在添加 android 平台时出现 'socket hang up' 错误。我怎样才能解决这个问题?先感谢您。这是我的代码:
//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
我解决了,这不是 API 问题。我刚刚重新安装了以下依赖项:
node.js, ionic, crodova- res.
我正在使用离子框架创建一个应用程序。之后我通过 cheerio scrape 创建了一个 API 并连接到 heroku 进行 Hattp 调用。问题是在添加 android 平台时出现 'socket hang up' 错误。我怎样才能解决这个问题?先感谢您。这是我的代码:
//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
我解决了,这不是 API 问题。我刚刚重新安装了以下依赖项: node.js, ionic, crodova- res.