I have incoming data to my Google Cloud Function and for some reason, my Google Cloud Function is getting the input from the client side in an incorrect format and is causing it to pass an undefined value to a web scraper I am attempting to build. I have tried passing the data as input = JSON.parse(req.body.input) and destructing it from the req.body and then parsing it and that did not work either. Attached here is the Google Cloud Function code as well as my client-side request (I think the client-side is OK, but I am a newbie so I could be completely off. The URL being passed into the fetch isn't the real URL, not posting it because I don't want that URL out in the open.) Any help for this struggling junior would be super appreciated!
Google Cloud Function
* Responds to any HTTP request.
*
* @param {!express:Request} req HTTP request context.
* @param {!express:Response} res HTTP response context.
*/
const puppeteer = require("puppeteer");
exports.webScrape = async (req, resp) => {
resp.header('Access-Control-Allow-Origin', '*')
console.log('working woot woot')
console.log(req.body)
resp.send('hello world')
};
Client-side request
try {
this.$emit("loading", true);
console.log("getting the scraper");
console.log(`here is input ${input}`);
//" "" "
const response = await fetch(
"myURL",
{
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Allow-control-allow-origin": "*",
},
body: JSON.stringify({ input }),
}```