I was creating a route that returns me all product names. However with javascript code is written like this:
getSku: function () {
return $.getJSON(Routing.generate(this.options.urls.get))
.promise();
},
So I am unable so far to extract the data from that response. If I console log this getSku I get:
{state: ƒ, always: ƒ, then: ƒ, promise: ƒ, pipe: ƒ, …}
always:ƒ ()
done : ƒ ()
fail : ƒ ()
pipe : ƒ ( /* fnDone, fnFail, fnProgress */ )
progress : ƒ ()
promise : ƒ ()
state : ƒ ()
then :ƒ ( /* fnDone, fnFail, fnProgress */ )
__proto__:Object
And when I remove .promise() I get:
{readyState: 1, getResponseHeader: ƒ, getAllResponseHeaders: ƒ, setRequestHeader: ƒ, overrideMimeType: ƒ, …}
abort:ƒ ( statusText )
always:ƒ ()
complete:ƒ ()
done:ƒ ()
error:ƒ ()
fail:ƒ ()
getAllResponseHeaders:ƒ ()
getResponseHeader:ƒ ( key )
overrideMimeType:ƒ ( type )
pipe:ƒ ( /* fnDone, fnFail, fnProgress */ )
progress:ƒ ()
promise:ƒ ()
readyState:4
responseJSON:Array(5)
0:{id: 1, identifier: "test_1", label: "test_1"}
1:{id: 2, identifier: "1000000", label: "1000000"}
2:{id: 3, identifier: "1000001", label: "1000001"}
3:{id: 4, identifier: "1000002", label: "1000002"}
4:{id: 5, identifier: "1000003", label: "1000003"}
And I need somehow to catch that responseJson result. But I don't know how to catch it. It is a backbonejs. I was looking for a various solutions but I always return undefined. Please, help me figure out how to get this json result. Thanks.