Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can i change the URL string i'm fetching from after each fetch?

I need to fetch 12 different nums for every object, and there are 31 different objects.

Basically, the API string ends like this:

/count?publishedAt_gte=2022-01-01&publishedAt_lte=2022-02-01&newsSite_contains=1&_limit=500

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

_contains=1′ determines the object, =2 will render the next one, =3 the one after and so forth until ‘_contains=31’

‘_gte=2022-01-01&publishedAt_lte=2022-02-01’ determines the specific num value, as changing the months (2022-01-01 becomes 2022-02-01 and 2022-02-01 becomes 03..) will return a different num.

So the function should fetch the num value from the base url, push it in a array, then raise the months numbers by 1 and repeat 12 times, to then return at the starting month to change the ‘contains’ part and raise it by 1 – all of this 31 times. So we’ll have 31 arrays, each with 12 nums.

Do you think it’s doable, and how?

>Solution :

If it runs with Node you can use the URL module. It has methods to get/set and such for the query params.

If it runs in the browser you can use the URLSearchParams web API.

Regarding implementation, you can tell me the environment this function would be invoked in and I can write something down for you.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading