-2

I want to get the key, value of the recorderEndpoint from the object.

presenter[6] outputs undefined

presenter = {
    id : sessionId,
    pipeline : null,
    webRtcEndpoint : null,
    presenterRoomNum : roomNum,
    roomName : presenterRoomName,
    presenterId : presenterId,
    recorderEndpoint : {uri: argv.file_uri}
}

I want these results. {recorderEndpoint : {uri: argv.file_uri}} What should I do?

sera
  • 73
  • 1
  • 9

3 Answers3

3

hope this will help you

let presenter = {
    id : 'sessionId',
    pipeline : null,
    webRtcEndpoint : null,
    presenterRoomNum : 'roomNum',
    roomName : 'presenterRoomName',
    presenterId : 'presenterId',
    recorderEndpoint : {uri: 'argv.file_uri'}
}

console.log(Object.entries( presenter))
akshay bagade
  • 1,169
  • 1
  • 11
  • 24
0

presenter is an object, not an array; you can't expect to index it by numbers.

The syntax you want is

presenter.recorderEndpoint

EDIT: based on the comment "I want these results. {recorderEndpoint : {uri: argv.file_uri}}":

x = {recorderEndpoint: presenter.recorderEndpoint}
AKX
  • 152,115
  • 15
  • 115
  • 172
0

You can also use quotes

presenter["recorderEndpoint"]
Kamil Naja
  • 6,267
  • 6
  • 33
  • 47