All api end-points now return text values with HTTP header content-type 'text/plain'

This commit is contained in:
joeuhren
2020-05-22 12:01:02 -06:00
parent d4a1b9cb16
commit 035141c389
2 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -63,7 +63,8 @@ app.use('/api', nodeapi.app);
app.use('/', routes);
app.use('/ext/getmoneysupply', function(req,res){
lib.get_supply(function(supply){
res.send(' '+supply);
res.setHeader('content-type', 'text/plain');
res.end(supply.toString());
});
});
@@ -87,7 +88,8 @@ app.use('/ext/getaddress/:hash', function(req,res){
app.use('/ext/getbalance/:hash', function(req,res){
db.get_address(req.params.hash, false, function(address){
if (address) {
res.send((address.balance / 100000000).toString().replace(/(^-+)/mg, ''));
res.setHeader('content-type', 'text/plain');
res.end((address.balance / 100000000).toString().replace(/(^-+)/mg, ''));
} else {
res.send({ error: 'address not found.', hash: req.params.hash})
}
+2 -1
View File
@@ -49,7 +49,8 @@ module.exports = function(){
res.json(response);
}
else{
res.send(""+response);
res.setHeader('content-type', 'text/plain');
res.end(response.toString());
}
}
});