These are my code blocks. API Endpoint
app.get('/clients/zvb/:id', function(req, res) {
console.log('ZVB Query loaded as var = file;')
var path = './public/queries/zvb.sql'
var zvb = fs.readFileSync(path, "utf8")
zvb = zvb.splice(25, 0, req.params.id)
request.query(zvb, function(err, recordset) {
console.log(recordset);
res.end(JSON.stringify(recordset));
});
})
Then my index.html where I try and GET the data from the endpoint.
$.ajax({
type: 'GET',
url: 'http://localhost:8081/clients/zvb/16601',
dataType: 'jsonp',
success: function(data) {
console.log(data);
console.log('we got to here..')
}
});
Not much is happening at the moment. When I try and manually run the ajax call in the terminal I get;
Object {readyState: 1}
The endpoint is working, if I view it I can see the JSON i'm after.
Tom