2
I’m starting now with Nodejs (I came from PHP), and I’m creating an API for an app of mine, I wonder, how do I make the queries based on Auth Basic, I don’t know very well how it works (I’ve already developed an app for a client, who always needed to send in the header Basic VGVzdDoxMjM=
, I’m not sure if it was for all queries, or just for login, but I would also like to restrict the query to my API. If not, just have the url of my API to be able to run a query
.
I am using Mysql for the database, follow the example of a query.
router.get("/menu", function(req, res){
let query = "SELECT * FROM ??";
let table = ["menu"];
query = mysql.format(query, table);
connection.query(query, function(err, rows){
if(err){
res.json({"Error": true, "Message": "Erro ao executar query do Mysql"});
}else{
res.json({"Error": false, "Message": "Sucesso", "Cardapio": rows});
}
})
})
Cool, got it, but how would it work to use Basic? like, can I just go via headers and etc? I don’t need anything else?
– Rafael Augusto
Yes, if it’s Basic it’s just that. It’s standard here if you want to check it out (https://tools.ietf.org/html/rfc7617)
– Danilo de Oliveira