박찬수

commit all

1 +function Emitter(){
2 + this.events = {};
3 +}
4 +
5 +Emitter.prototype.on = function(type, listener){
6 + this.events[type] = this.events[type] || [];
7 + this.events[type].push(listener);
8 +}
9 +
10 +const emitter = new Emitter();
11 +
12 +emitter.on('soccer', function(){
13 + console.log('soccer logged.');
14 +})
15 +
16 +Emitter.prototype.emit = function(type){
17 + if(this.events[type]){
18 + this.events[type].forEach(function(listener){
19 + listener();
20 + });
21 + }
22 +}
23 +
24 +emitter.emit('soccer');
...\ No newline at end of file ...\ No newline at end of file
1 -module.exports = { 1 +var request = require('request');
2 - GetPlayerInfo : function(playerID, season){
3 - var request = require('request');
4 var options = { 2 var options = {
5 method: 'GET', 3 method: 'GET',
6 url: 'https://v3.football.api-sports.io/players', 4 url: 'https://v3.football.api-sports.io/players',
7 - qs: {id: playerID, season: season}, 5 + qs: {id: 276, season: 2019},
8 headers: { 6 headers: {
9 'x-rapidapi-host': 'v3.football.api-sports.io', 7 'x-rapidapi-host': 'v3.football.api-sports.io',
10 'x-rapidapi-key': '526fc70a2e8b315e9a960ac4b4764191' 8 'x-rapidapi-key': '526fc70a2e8b315e9a960ac4b4764191'
...@@ -12,7 +10,6 @@ module.exports = { ...@@ -12,7 +10,6 @@ module.exports = {
12 }; 10 };
13 request(options, function (error, response) { 11 request(options, function (error, response) {
14 if (error) throw new Error(error); 12 if (error) throw new Error(error);
15 - console.log(response.body);
16 }); 13 });
17 - }
18 -}
...\ No newline at end of file ...\ No newline at end of file
14 +
15 +
...\ No newline at end of file ...\ No newline at end of file
......