JrProgrammeur JrProgrammeur - 3 months ago 13
Javascript Question

Get id (undefined) of object

I have an code if I do console.log(resp) I got to see enter image description here (see img) but when I do console.log(resp[id]) of console.log(resp[{id}])

I see undefined.

How can I access the id that is been created ?

var request = gapi.client.request({
'path': '/drive/v2/files/',
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
"title" : name,
"mimeType" : "application/vnd.google-apps.folder",
"parents": [{
"kind": "drive#file",
"id": FOLDER_ID,

this is the code I use. the id is not the same id as id : FOLDER_id

how can I access that id ?


Your accessing the property the wrong way, try this

resp.id or resp["id"]

Note the second way is wrapped into quote to make it a string.