Get specific value of JSON

0

I have an API that returns the corresponding image of a status, but I'm having trouble picking only the 'pathname' field in my API response.

API Response:

({"code":1,"msg":"OK","details":[{"caminhofoto":"https:\/\/localhost\/sistema\/assets\/images\/status\/pendente.gif"}],"request":"{\"status\":\"pending\"}"})

Code that I'm using to get the field path:

$.ajax({
    type:"GET",
    url:"https://localhost/sistema/mobileapp/api/getImagemStatus?status=pending",
    data: { get_param: 'caminhofoto' }, 
    dataType: 'jsonp',
    success: function(data) {
        //Aqui tento pegar apenas o campo caminhofoto
        var foto = data['caminhofoto'];

        console.log("ENTROU AQUI "+foto)


    },

  });

On the console I get the log: Enter here undefined

    
asked by anonymous 28.04.2018 / 14:54

1 answer

1

The photo path is inside details, at position 0 of the array.

console.log(data.details[0].caminhofoto);
    
28.04.2018 / 15:14