title: Node.JS https request return JSON
body: <p>I have a question about the Node.js HTTPS request.
  The request goes to a server,which will return a JSON response. Then I want to parse the response and store it in a variable and use it with other functions.</p>
  
  <pre><code>let obj=JSON.parse(response);
  return obj;
  </code></pre>
  
  <p>The functions I have written:</p>
  
  <pre><code>let protocol="https";
  let hostStr="www.example.com";
  let pathStr="***";
  
  let students=makeRequest("ABCDEFG","getStudents"));
  console.log(students);
  
  function makeRequest(token,method){    
         let obj='';
          let options={
              host:hostStr,
              path:pathStr,
              method:"POST",
              headers:{"Cookie":"JSESSIONID="+token}
          };
          let https=require(protocol);
          callback = function(response){
              var str='';
  
              response.on('data',function(chunk){
                  str+=chunk;
              });
  
              response.on('end',function(){
                  obj=JSON.parse(str);
              });
          }
          let request=https.request(options,callback);
          request.write('{"id":"ID","method":"'+method+'","params":{},"jsonrpc":"2.0"}');
          request.end();
          return obj;
      }
  </code></pre>
  
  <p>I hope you can help me</p>