I am trying to fetch data based on a query. However, if i pass a query to my api call and format the queryString. The result will look like this:
Object {"DE": null,"limit": 10,"offset": 0,}
When fomratted correctly, the Object should look like this:
Object {"query": "DE","limit": 10,"offset": 0,}
(For showcasing my issue I set a default value fro my query). My API call looks like this:
export function thunkFetchOrders( query = 'DE', offset = 0, limit = 10, filters = {}) { return async (dispatch: any) => { if (offset === 0) { dispatch( resetOrders() ) } let requestParams = { offset, limit, } requestParams = {...requestParams, ...setFilter(filters)} if (query) { requestParams = {...requestParams, ...queryString.parse(query)} } try { const res = await axios.get(`/orders`, {params: requestParams}) await dispatch( fetchOrders( res.data, limit, offset, filters ) ) } catch (error) { await dispatch(thunkFetchError(error)); } }}
What am I doing wrong here?