values endpoint

node v10.24.1
version: 1.0.0
endpointsharetweet
exports.endpoint = function(request, response) { console.log(request.method); let body = ''; request.on('data', (chunk) => { body += chunk; }); request.on('end', () => { console.log('body:', body); if (!body) { body = '{}'; } const { meta: { params: { value = 0 } } } = JSON.parse(body); const toSend = Array.isArray(value) ? value.map(n => ({ label: `number ${n}`, value: n })) : { label: `number ${value}`, value }; response.setHeader('Content-Type', 'application/json'); response.end(JSON.stringify(filtered));
Loading…

no comments

    sign in to comment