Answer the question
In order to leave comments, you need to log in
Why is the POST array not being passed?
I'm trying to understand why the POST transmission does not work.
index.js
files
const express = require('express');
const hchrome = require('./hcr');
const app = express();
const port = 3000;
app.get('/content', async (request, response) => {
var url = request.query.url;
var content = await hchrome.process(url);
console.log(url);
response.send(content);
});
app.listen(port, (err) => {
if (err) {
return console.log('error', err)
}
console.log(`server is listening on ${port}`)
});
const puppeteer = require('puppeteer');
async function content(url) {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto(url);
await page.waitFor(1000);
const content = await page.content();
await browser.close();
return content;
}
exports.process = function (url) {
var result = content(url).then((value) => {
return value;
});
return result;
}
HTTP/1.1 404 Not Found X-Powered-By: Express Content-Security-Policy: default-src 'none' X-Content-Type-Options: nosniff Content-Type: text/html; charset=utf-8 Content-Length: 147 Date: Thu, 10 Oct 2019 07:10:39 GMT Connection: keep-alive
Cannot POST /content
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question