A
A
Alex Ivanov2019-10-10 10:11:48
Node.js
Alex Ivanov, 2019-10-10 10:11:48

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}`)
});

hcr
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;
}

When I try to send data via Curl I get a response
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

If without POST transmission that works fine, but unfortunately not functional enough.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question