I
I
Ivan Ivanovich2020-07-16 07:56:03
API
Ivan Ivanovich, 2020-07-16 07:56:03

How to work with api?

Hello, I am writing a project on pure node.

There is a task to write a payment handler. On this occasion I would like to ask a few questions.

1. You need to check the ip from which the request came. Those. there is an array with trusted ips, but how can I find out the ip from which the handler is being called?

Will it fit request.connection.remoteAddress?

2. Post parameters also come. If in php I would receive them via $_POST, then how can I do it in pure node js? I think this design will not be relevant?

let body = '';
    req.on('data', data=>{
       body += data.toString();
    });


3. After processing the payment, you need to answer OK. Would it be ok to just do res.end('OK')?

Thank you all in advance!

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