Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- const https = require('https');
- exports.handler = (event, context, callback) => {
- // API Key
- const api_key = "RGAPI-";
- // Set the options for the https request
- const options = {
- hostname: event['pathParameters']['region'] + ".api.riotgames.com",
- port: 443,
- path: "/lol/summoner/v3/summoners/" + event['pathParameters']['id'] + "?api_key=" + api_key,
- method: "GET"
- };
- // Make the https request
- const req = https.request(options, (res) => {
- let body = '';
- res.setEncoding('utf8');
- res.on('data', (chunk) => body += chunk);
- res.on('end', () => {
- let response = {
- "statusCode": res.statusCode,
- "headers": {
- "Access-Control-Allow-Origin": "*",
- "Access-Control-Allow-Headers": "Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token",
- "Access-Control-Allow-Credentials": true,
- "Content-Type": "application/json"
- },
- "body": body
- }
- callback(null, response);
- });
- });
- req.on('error', callback);
- req.end();
- };
Add Comment
Please, Sign In to add comment