There is a need to execute an API call with specific parameters.
Here is an example:
const apiFunc = (someId, anotherId) => apiCall(someId, anotherId)
However, when the data is stored in an array named someArr
, it appears like this:
[1, 'someId', 2, 'anotherId', 3, 'anotherId', 4, 'someId']
The goal is to utilize values in the function apiCall()
based on certain conditions. For instance, if 1
(same as 4
) is followed by 'someId'
, then use it, and if 2
(same as 3
) is followed by 'anotherId'
, then use it.
Could you please suggest how to properly structure this to achieve the desired outcome?
Thank you.
I have attempted using .includes()
method but it hasn't been very successful.