1

console.log(body) printing the correct result but when am using body.payment_request.longurl it's showing TypeError: Cannot read property 'longurl' of undefined.

I am trying to add payment interface in my meteor project.

request.post('https://test.instamojo.com/api/1.1/payment-requests/', {form: payload,  headers: headers},  function(error, response, body){
        //console.log(body.success);
        if(!error && response.statusCode == 201){
            console.log(body);
            console.log(body.payment_request.longurl);

        }

      });

outputs

{
     "success": true,
     "payment_request": {
         "id": "6d2d4f0d56984486a1b325a13db59678",
         "phone": "+919999999999",
         "email": "foo@example.com",
         "buyer_name": "John Doe",
         "amount": "2500.00",
         "purpose": "FIFA 16",
         "expires_at": null,
         "status": "Pending",
         "send_sms": true,
         "send_email": true,
         "sms_status": "Pending",
         "email_status": "Pending",
         "shorturl": null,
         "longurl": "https://test.instamojo.com/@rathore16696/6d2d4f0d56984486a1b325a13db59678",
         "redirect_url": "http://www.example.com/redirect/",
         "webhook": "http://www.example.com/webhook/",
         "allow_repeated_payments": false,
         "customer_id": null,
         "created_at": "2019-02-
         "modified_at": "2019-02-02T15
}

TypeError: Cannot read property 'longurl' of undefined.

Yennefer
  • 5,704
  • 7
  • 31
  • 44

0 Answers0