Saturday, 13 May 2017

make api call to get json data

I was trying to get json data from this api, but only thing i'm getting is the html of the page that i would normally get if i opened this link in browser

base url for accessing the api http://sc.productrx.com/public/

Action: Get survey table
HTTP Verb: GET
Rest Resource: schema
Description of parameters, etc: get schema Table name ("survey")

this is what i have tried so far

app.get('/',function(req,res){

   console.log(req.method+" request received at "+req.url);


request({
     url:"https://sc.productrx.com/public/",
     method:"GET",
     qs:{resource:"schema",data_type:"JSON"}
     },function(err,response,body){
          if(err){
              console.log(err);
              res.status(300).json(error.apiError);
            }
          else{
              console.log(body);
              //var body=JSON.parse(body);
              //res.status(200).json({"success":true,"body":body.users});
            }
        });  });



via Ayush Singh

No comments:

Post a Comment