Trying to get the "to:phoneNumber" but can't seem to get the code correct.
API response.
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/65464/extension/56454/message-store?availability=Alive&dateFrom=2022-09-27T13:23:00.000Z&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/3212/extension/21321/message-store/6545645644",
"id": 656554654,
"extensionId": "6545454",
"to": [
{
"phoneNumber": "+12148583212"
}
],
"from": {
"phoneNumber": "+18174568368",
"name": "Test Test",
"location": "Dallas, TX"
},
"type": "SMS",
"creationTime": "2022-10-19T20:11:33.000Z",
"readStatus": "Read",
"priority": "Normal",
"attachments": [
{
"id": fddd,
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/5317fd86048/extension/fd/message-store/fd/content/fd",
"type": "Text",
"contentType": "text/plain"
}
],
"direction": "Outbound",
"availability": "Alive",
"subject": "This is a text message from Restoration Pro using the approved ring central API integration. ",
"messageStatus": "Delivered",
"smsSendingAttemptsCount": 1,
"conversationId": fdddf,
"conversation": {
"id": "fdff",
"uri": "https://platform.ringcentral.com/restapi/v1.0/conversation/dfdf"
},
"lastModifiedTime": "2022-10-19T20:11:36.074Z"
},
JavaScript
var d = getRingCentralMessages.data.records
var outArr = []
d.forEach((a) => {
outArr.push({
creationTime: a.creationTime,
to: a.to.phoneNumber,
from: a.from.phoneNumber,
direction: a.direction,
subject: a.subject
})
})
return outArr;
results in undefined for to.phoneNumber