On Monday, 2 February 2026 at 16:47:52 UTC, Lars Johansson wrote:
hi all, this is driving me nuts.My client code: I call the server once for each node in the array endpoints.but the result (see below) is three calls with the last element (/times) i have tried a zillion times in vain, they all ends with three (/times) call. the only way i can get this right is by break out the calling logic to a function like void spawnRequest(string ep){...} and thus creating a copy per call I suppose.Two things: It works but, it is a clumsy solution. And I'm not really sure why it goes wrong.i would appreciate if someone can show me a clean solution without a 'technical' function. and why my solution goes wrongimport vibe.vibe; import std.stdio : writefln; import std.stdio : writeln; void main(){string[] endpoints = ["/", "/hello/VibeClient", "/time"];foreach (endpoint; endpoints) { writeln("start ",endpoint); auto ep = endpoint; runTask(() nothrow @safe { try {auto response = requestHTTP("http://127.0.0.1:8080" ~ ep); auto body = response.bodyReader.readAllUTF8();() @trusted { writefln("[%s] Response: %s", ep, body); }(); } catch (Exception e) { try { () @trusted {writefln("[%s] Error: %s", ep, e.msg);}(); } catch (Exception) {} } }); } runApplication(); } result: PS C:\Users\Lasse\DUB\nwclient01> ./nwclient01.exe start / start /hello/VibeClient start /time [/time] Response: Current time: 2026-02-02T17:28:07.6319941 [/time] Response: Current time: 2026-02-02T17:28:07.632999 [/time] Response: Current time: 2026-02-02T17:28:07.632999
Use:
```d
runTask(() nothrow @safe {...}, ep );
```
see https://vibed.org/api/vibe.core.core/runTask
