node js: send get request, save response Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of node js: send get request, save response without wasting too much if your time.

The question is published on by Tutorial Guruji team.

edited, i cut it short.

code variable is assigned

firstly i need to trigger a php script with get request, output shouldn’t be saved "" + code

then, when the request above completed, send get request to "" + code and save the response to a variable,

for it should be 6, see the url

i tried fetch, no result


You have to await it as text:

const resultValue = await fetch(`${code}`).then(res => res.text());
// (if code === ii, resultValue = "6")
let resultAsInt = parseInt(resultValue);
We are here to answer your question about node js: send get request, save response - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji