Monday, 15 May 2017

How to consume POST call where parameter is of type application/x-www-form-urlencoded in node js

I have a rest call,where it requires one parameter empid to be passed of type

 application/x-www-form-urlencoded

enter image description here

Iam trying to consume that using the following code.But the value is getting passed as undefined to the restcall

 function searchEmployee(employeeid){
        var empEndpoint = 'http://localhost:3001/searchemp';
        var http = new XMLHttpRequest();
        http.open('POST',empEndpoint,true);
        http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
        var empid = employeeid;
        http.send(empid) ;
    }

Please can someone point out the mistake and help me how to POST that in proper format.



via user7350714

No comments:

Post a Comment