Skip to content

Instantly share code, notes, and snippets.

@P1xt
Created March 18, 2017 03:20
Show Gist options
  • Save P1xt/f139643e509bedec9f2bdc7b0e8339c3 to your computer and use it in GitHub Desktop.
Save P1xt/f139643e509bedec9f2bdc7b0e8339c3 to your computer and use it in GitHub Desktop.
Services to read Twitch.tv API data from the FCC proxy on gomix
import { Injectable } from '@angular/core';
import { Http, Headers, Response, Jsonp, URLSearchParams } from '@angular/http';
@Injectable()
export class GetTwitchService {
constructor(private json: Jsonp) { }
getStreamer = (streamer) => {
let params = new URLSearchParams();
params.set('callback', 'JSONP_CALLBACK');
let apiUrl: string = 'https://wind-bow.gomix.me/twitch-api/users/'+streamer;
return this.json
.get(apiUrl, { search: params })
.map(response => response.json());
}
getStream = (streamer) => {
let params = new URLSearchParams();
params.set('callback', 'JSONP_CALLBACK');
let apiUrl: string = 'https://wind-bow.gomix.me/twitch-api/streams/'+streamer;
return this.json
.get(apiUrl, { search: params })
.map(response => response.json());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment