sh-at-proxy

node v10.24.1
version: 5.0.0
endpointsharetweet
var https = require('https'); exports.endpoint = function(request, response) { var query = require('url').parse(request.url, true).query.aq; console.log(query); var app_id = process.env.app_id; var app_key = process.env.app_key; var url = "api.airtable.com"; var mypath = "/v0/" + app_id + '/Albums?view=Grid view&filterByFormula=FIND(LOWER("' + query + '"),LOWER({Album Name}))' var encodedmypath = encodeURI(mypath); var options = { host: url, port: 443, path: encodedmypath, method: 'GET', headers: { 'Authorization': 'Bearer ' + app_key, 'Accept': 'application/json' } }; var atResult; https.request(options, function(res) { console.log('STATUS: ' + res.statusCode); console.log('HEADERS: ' + JSON.stringify(res.headers)); res.setEncoding('utf8'); res.on('data', function (chunk) { console.log('BODY: ' + chunk); atResult = chunk; }); res.on('end', function () { response.writeHead(200, { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': '*', }); response.end(atResult); }); }).end(); }
Loading…

no comments

    sign in to comment