For example, you have a google protobuf message Customer with repeated field like below.
message Customer {
repeated int32 items = 1;
}
How do you set the repeated items field in javascript?
To set the repeated field in javascript,
You can use either setItemsList or addItems methods.
For example, to use setItemsList method
let customer = new Customer(); customer.setItemsList([12, 123, 1234]);It will set the value of items to the javascript array.
Or for another example, to use addItems method
let customer = new Customer(); customer.addItems(123);It will append the value of 123 to the list of items in the message.
For more info, you can check out the protobuf docs for repeated field in javascript.