I want to execute a CQL query on a node.js server which can be requested from a client/browser. I send the following query:
localhost:3000/selectquery?query="select * from simplex.songs;"
I am using the following GET method to execute the request:
app.get('/selectquery',function(req,res){
var query_string = req.query.query;
console.log(query_string);
client.execute(query_string,function(err,result){
if(err){
console.log(err);
res.status(404).send(err);
}
else{
res.json(result);
}
});
});
When I make any request,I get the following error message:
{
"name": "ResponseError",
"message": "line 1:0 no viable alternative at input 'select * from simplex.songs;'",
"info": "Represents an error message from the server",
"code": 8192,
"query": "\"select * from simplex.songs;\""
}
It think, i need to parse the query_string
and remove "
or '
from the query. How I can do this?
Aucun commentaire:
Enregistrer un commentaire