How to pass database query in Angular Get API URL

40 Views Asked by At

I have below function in my service file which i am executing from Component, i want to prepare one get URL from below function.

getStartEndTime(body) {
    const query = `select min(shiftstart) starttimeofmonth,max(shiftend) endtimeofmonth from ShiftCalendarDeDup where lineid=${body.lineId} and factoryid=${body.factoryId} and businessdate between ${body.firstDay} and ${body.lastDay}`;
    return this.http.get(`${environment.apiDFOS3BaseUrl}/dfosbroker/generic/query/${query}`);
  
  }

But above code generates below URL in the Network tab

URL :

https://dfos-qa.unilever.com/dfosbroker/generic/query/select%20min(shiftstart)%20starttimeofmonth,max(shiftend)%20endtimeofmonth%20from%20ShiftCalendarDeDup%20where%20lineid=E_A571_A%20and%20factoryid=E_A571%20and%20businessdate%20between%202023-10-01%20and%202023-10-31

My expected output

https://dfos.unilever.com/dfosbroker/generic/query/select min(shiftstart) starttimeofmonth,max(shiftend) endtimeofmonth from ShiftCalendarDeDup where lineid='R_A002_MAFLRIA1' and factoryid='R_A002' and businessdate between '2023-10-01' and '2023-10-31'

Can anyone help me to get my expected output.

0

There are 0 best solutions below