I received the following object (Survay) JSON format from server
/**************************************/
{
"id": 870,
"title": "test survay ",
"questions": [
{
"id": 871,
"data": "question data 1"
},
{
"id": 874,
"data": "question data 2"
},
{
"id": 877,
"data": "question data 3"
}
],
"user": {
"id": 788,
"name": "mohamed",
"answres": [
{
"data":"answere question 1"
},
{
"data":"answere question 2"
},
{
"data":"answere question 3"
}
]
}
}
I used the following code
getSurvayByid(id: number) {
const headers = new HttpHeaders({
'Authorization': this.loadToken(),
'Content-Type': 'application/json'
});
return this.http.get<Survay>(this.host + "/survay/" + id, { headers: headers })
.pipe(map(resp => resp));
}
I would like to change this format as it’s displayed:
My question:how I can get this format using the Rxjs operators ? (map, take, pipe...) and change the method getSurvayByid(id: number)
{
"id": 870,
"title": "test survay ",
"questions": [
{
"id": 871,
"data": "question data 1",
"answer":"answere question 1"
},
{
"id": 874,
"data": "question data 2",
"answer":"answere question 2"
},
{
"id": 877,
"data": "question data 3",
"answer":"answere question 3"
}
],
"user": {
"id": 788,
"name": "mohamed"
}
}