3

I have api url like this:

https://example.com/api/tickets?filters=[{"field":"ticket_number","op":"like","value":"HT00002"}] 

And I've created service function like this:

getTableFilter(column: string, sort: string, value: string) { const accessToken = store.get('accessToken') const params = accessToken ? { headers: { Authorization: `Token ${accessToken}`, AccessToken: accessToken, }, } : {} return this.http .get(`${this.env.HELPDESK_LIST_FILTER}` + '[{field:' + column, + 'op:' + sort, + 'value:' + value + '}]', params) .pipe(map((data) => data)); } 

Note: this.env.HELPDESK_LIST_FILTER is equal to 'https://example.com/api/tickets?filters=' in my env file

But I get this error

one

Any idea?

3 Answers 3

2

you have accidently apply more that two parameter try to stick with `` string format

 this.http.get(`url`,params) 
const url = `${this.env.HELPDESK_LIST_FILTER}[{field: ${column},op:${sort},value:${value}}]`; const params = accessToken ? { headers: { Authorization: `Token ${accessToken}`, AccessToken: accessToken, }, } : {}; return this.http .get(url, params) .pipe(map((data) => data)); 
Sign up to request clarification or add additional context in comments.

Comments

1

The comma should be in the quote.

return this.http .get(`${this.env.HELPDESK_LIST_FILTER}` + '[{field:' + column + ',op:' + sort + ',value:' + value + '}]', params) .pipe(map((data) => data)); 

Comments

1

I would highly recommend to create a String before the call and assign the value instead of creating the String in the Get Request,

 const serviceUrl = `${this.env.HELPDESK_LIST_FILTER}` + '[{field:' + column, + 'op:' + sort, + 'value:' + value + '}]'; return this.http .get(serviceUrl,params) .pipe(map((data) => data)); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.