My PB Schema looks like below:
message ProductRecommendationReply {
string productid = 1;
message recommendationlist{
string recommendedproductid = 1;
string recommendedproductname = 2;
string recommendedproductprice = 3;
}
}
At the server side (node.js), I am trying to set the properties like below:
var message = {
productid: '',
recommendationlist: []
};
message.productid = result_list.product_Id;
message.recommendationlist.recommendedproductid = result_list.recomendation_list[0].recommended_product_id;
message.recommendationlist.recommendedproductname = result_list.recomendation_list[0].recommended_product_name;
message.recommendationlist.recommendedproductprice = result_list.recomendation_list[0].recommended_product_price;
callback(null,message); // send the result back to consumer.
The problem is when debugging the clinet side, only the productid
has a value assigned to it, the recommendationlist
is empty.
How can I properly assign a value to the nested message?
You defined a message but didn't declare a field of that message type. I think you mean to do
message ProductRecommendationReply {
string productid = 1;
message productrecommendationlist {
string recommendedproductid = 1;
string recommendedproductname = 2;
string recommendedproductprice = 3;
}
repeated productrecommendationlist recommendationlist = 2;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With