3 of 3 Add template string

As you can see in the URL, you pass "${encodeURIComponent...}" as a string, not as evaluated value. Your code is probably something like:

url = 'https://friendbot(...)?addr=${encodeURIComponent...}';

but should be like:

url = 'https://friendbot(...)?addr=' + encodeURIComponent...;
// or as a template string
url = `https://friendbot(...)?addr=${encodeURIComponent...}`;

...and since the public keys do not contain special characters, it's not neccessary to escape it.

url = 'https://friendbot(...)?addr=' + pair.publicKey();