Where should "InputStream" be created in a 1 FPS callback

if the title isnt too clear as to what i’m asking;

i have a timer, running at 1 refresh per second, that connects to an external api thru URL.
the function of this timer class is just to update text.

here is what im currently trying, but every second the app freezes when being dragged:

void timerCallback() override
		{
			stream = default_url.createInputStream
			(
				false,
				nullptr,
				nullptr,
				String{},
				100,
				nullptr,
				nullptr,
				1,
				String{}
			);
			
		}

should i be calling createNewInputStream every callback? or is it something that should only be used if the url changes? how do i set it up so that i can get information every second without freezing on drag?

thanks!

SOLVED
using Thread.

Thread
custom update() function as thread is inherited privately

        void update() { startThread(1); }

        void run() override
		{
			var parsed;
            // --- re-implement json when working
			info = newStream()->readEntireStreamAsString();
		}

		std::unique_ptr<InputStream> newStream()
		{
			StringPairArray responseHeaders;
			int statusCode = 0;
			return default_url.createInputStream
			(
				false,
				nullptr,
				nullptr,
				String(),
				10000,
				&responseHeaders,
				&statusCode
			);
		}

Callback

scanner.update(); 
repaint();

Hope this helps others.