I think the issue you are experiencing, where the value of r is only printed once, is likely due to the fact that the fetch function is asynchronous, meaning that the code after it will be executed before the HTTP request has completed. This means that the value of r may not be set when you try to print it multiple times. To fix this, you can move the code that relies on the value of r inside the then block, so that it is only executed after the HTTP request has completed and the value of r has been set.