UNPKG

huli-metrics-angular

Version:
31 lines (27 loc) 664 B
'use strict'; declare function require(path: string): any; require('es6-promise').polyfill(); require('isomorphic-fetch'); export class Metrics { static send(applicationName, serviceName) { return fetch('http://52.47.59.43/event', { body: JSON.stringify({ time: Date.now(), level: serviceName, service_name: applicationName, }), headers: { 'content-type': 'application/json' }, method: 'POST', }) .then((response) => { if(response.status != 200) { throw new Error('Bad response :(') } else { (response.json()) } }) .then(data => (data)); } };