Search code examples
javascriptangularjsresponse

Retrieving data from http.get response in angularjs


How can I get this 'couponId' from the response data in javascript. I tried response.data.data in an alert but it gives object[object]. I want to store this 'couponId' in a var. I successfully get others like this just fine.. response.data.success and response.data.error_description

{"success":"yes","data":{"couponId":"31"},"error_code":"","error_description":""}

Solution

  • You can get couponId by using data.data.couponId