Skip to content

Commit 31a15ab

Browse files
authored
Merge pull request #1196 from data-for-change/1195-modify-patch
modify patch request
2 parents 6788b2c + 451990e commit 31a15ab

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/services/news.data.service.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,27 @@ function onErrorFetchNewsFlash() {
6868
return errorArr;
6969
}
7070

71-
export function updateNews(newsId: number, newLocationQualification: any,
72-
streetLocation: IStreetData | null, gpsLocation: IGpsData | null) {
73-
const data = [];
74-
data.push(`newsflash_location_qualification=${newLocationQualification}`)
71+
export function updateNews(
72+
newsId: number,
73+
newLocationQualification: any,
74+
streetLocation: IStreetData | null,
75+
gpsLocation: IGpsData | null
76+
) {
77+
const payload: any = {
78+
newsflash_location_qualification: newLocationQualification,
79+
};
80+
7581
if (gpsLocation) {
76-
data.push(`road_segment_id=${gpsLocation.road_segment_id}`)
77-
data.push(`road1=${gpsLocation.road1}`)
82+
payload.road_segment_id = gpsLocation.road_segment_id;
83+
payload.road1 = gpsLocation.road1;
7884
} else if (streetLocation) {
79-
data.push(`yishuv_name=${streetLocation.city.yishuv_name}`)
80-
data.push(`street1_hebrew=${streetLocation.street.street_hebrew}`)
85+
payload.yishuv_name = streetLocation.city.yishuv_name;
86+
payload.street1_hebrew = streetLocation.street.street_hebrew;
8187
}
82-
const url = `${NEWS_FLASH_API}/${newsId}?${data.join('&')}`;
83-
axios
84-
.patch(url, {}, { withCredentials: true })
88+
89+
const url = `${NEWS_FLASH_API}/${newsId}`;
90+
return axios
91+
.patch(url, payload, { withCredentials: true })
8592
.then((res) => res.data)
86-
.catch(onErrorFetchNewsFlash)
87-
}
93+
.catch(onErrorFetchNewsFlash);
94+
}

0 commit comments

Comments
 (0)