How can you pass multi-line strings (with spaces and tabs) as a parameter to an express server?
Express.js code that accepts the parameter :
app.get('/:prompt', async (req, res) => {
const prompt = req.query.prompt;
// Do something with the prompt and send a response
}
Client-Side Javascript code that tries to send a multi-line string :
export function btn_click() {
console.log('Clicked')
const prompt = $w("#textBox1").value
// console.log(typeof prompt);
const Orignal_URL = 'https://11bf-2401-4900-1f35-97fc-68a4-6e62-bb93-34d5.in.ngrok.io/';
const URL = Orignal_URL.concat(prompt)
console.log(URL);
fetch(URL, { method: 'get' })
.then(res => res.json())
.then(ans => {
console.log(ans);
const blank = $w("#text3");
if (ans['Answer'] === undefined){
blank.text = 'Please enter the required information';
}
else {
blank.text = String(ans['Answer']);
}
blank.show()
});
}
When I send a multi-line string as the parameter, the variable "prompt" is equal to "undefined". How do I solve this?
Update: Added the code that sends a request with the string for more clarity