My route setup is like this:
app.all("/checkoutupdateprods", async (res,req, next) =>{
const url = GRAPHQL_CUSTOM_URL;
console.log("in b_server.js", res.body);
let data = res;
await fetch(url, checkOut_ProductsInStock(data.body))
.then(res => console.log(res.json()))
.catch(err => req.send(err));
});
When initiating the process from the client side, I send a JSON string to the server. Subsequently, I generate a GraphQL query using this JSON string containing necessary IDs. The said query along with the URL is then used to make a GET request to Shopify in order to retrieve the required products.
This is why I have opted for utilizing app.all(), enabling me to perform both POST and GET actions within a single route. However, I am currently facing an issue where the response (res) is being assigned the POST JSON string from the client rather than the anticipated outcome from Shopify regarding the necessary products.
I am seeking suggestions on how to address this concern. Any advice?
EDIT**--- I have made adjustments as follows, but I am encountering a situation where the promise remains pending without resolution.
app.post("/checkoutupdateprods", async (req,res, next) =>{
const url = GRAPHQL_CUSTOM_URL;
console.log(req.body);
let data = req;
await fetch(url, checkOut_ProductsInStock(data.body))
.then(res => console.log(res.json()))
.catch(err => res.send(err));
});