So I'm trying to replace the following url with appropriate value from my matchedResult object:
var matchedResult={
"username": "foo",
"token": "123"
}
var oURL = "https://graph.facebook.com/#{username}/posts?access_token=#{token}";
I have tried the following:
var matchedResult={
"username": "foo",
"token": "123"
}
var match,
regex = /#\{(.*?)\}/g,
oURL = "https://graph.facebook.com/#{username}/posts?access_token=#{token}";
while (match = regex.exec(oURL)) {
oURL.replace(match[0], matchedResult[match[1]])
}
console.log(oURL);
but still the result is
"https://graph.facebook.com/#{username}/posts?access_token=#{token}"
instead of
What am I doing wrong here?