Sending body data through PHP/WordPress to my backend

enter image description here

I have in the frontend this function that sends data to the backend through a proxy in wordpress/php:

                url: ICapiEndpoint,
                type: 'POST',
                data: {
                    name: document.getElementById('icName').value, //<= I NEED THIS VALUE in backend
                    action: "get_search_suggestions",
                success: function (result) {
                error: function (error) {

In php I got this functions:

add_action('wp_ajax_ic_copy_nodes', function() {
    $api = new ArangoConnector();
    $data = stripslashes($_POST["data"]);


public function getSuggestions($data)
    $data = ($data);
    $json = json_decode($data);
    $url = $this->getBaseUrl() . self::SEARCH_SUGGESTIONS;
    $response = wp_remote_get($url, self::getDefaultArgs());
    return self::generateResponse($response);

I know its working because in my backend which is in node.js I’m printing the request and I’m getting:

As you can see there is no namevalue in there. How to receive the name value that I’m sending in the frontend. I know its something I’m missing in php.

Read more here: Sending body data through PHP/Wordpress to my backend

Leave a Reply

Your email address will not be published. Required fields are marked *