Fixed!!! The issue is that having the 'params' inside an string like this:
"params=hexcode${keyword}hexcode" makes the interpreter to not extract the value for ${keyword}
Instead of that in your code define 2 new var like this: var left = "params=hexcode%22"
This var has 'all the text on the left of the actual keyword you want to add'
var right = "%22hexcode"
Now in addAlert(i) build a new params var containing the term you want to add in your google alert like this:
function addAlert(i) { // Retrieve the keyword to work with const keyword = encodeURIComponent(keywords[i])
//build the params var with the term to be added var params = left + keyword + right
And all that's left is to use it (without any '$') in your fetch getting something like this:
"referrer": "google.es/alerts", "referrerPolicy": "strict-origin-when-cross-origin", "body": params, "method": "POST", "mode": "cors", "credentials": "include"
I hope this will help anyone!!!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Fixed!!! The issue is that having the 'params' inside an string like this:
"params=hexcode${keyword}hexcode" makes the interpreter to not extract the value for ${keyword}
Instead of that in your code define 2 new var like this:
var left = "params=hexcode%22"
This var has 'all the text on the left of the actual keyword you want to add'
var right = "%22hexcode"
This var has 'all the text on the left of the actual keyword you want to add'
Now in addAlert(i) build a new params var containing the term you want to add in your google alert like this:
function addAlert(i) {
// Retrieve the keyword to work with
const keyword = encodeURIComponent(keywords[i])
//build the params var with the term to be added
var params = left + keyword + right
And all that's left is to use it (without any '$') in your fetch getting something like this:
"referrer": "google.es/alerts",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": params,
"method": "POST",
"mode": "cors",
"credentials": "include"
I hope this will help anyone!!!