I want to send some data from drupal 8 through guzzle through a "POST" method to my nodejs server, do something with the data and send it back to drupal modified.

How can I achieve this? I have never used requests or haven't done anything like this before.

My node server code looks like this :

 response.writeHead(200, {'Content-Type': 'application/json'});
 response.write('response sent')


And my code from drupal:

        public function sendNodeData($links){
            $url = 'http://localhost:8000';

            $client = new \GuzzleHttp\Client();

            $res = $client->request('POST', $url, ['json' => $links]);

            $response = $res->getBody();

In the console of the node server I get undefined when I log the request.body. So I'm guessing my server setup is wrong

0 Answers