<commit_before>import { Injectable } from '@angular/core';
import {Http} from "@angular/http";
import {Observable} from "rxjs/Observable";

/**
 * Custom post method to handle all Http POSTS in the app
 * @param url
 * @param data
 * @returns {Observable<R|T>}
 */

@Injectable()
export class HttpClientService {

  constructor(private http: Http) { }

  public post(url, data, headers) {
    return this
      .http
      .post(url, JSON.stringify(data), {headers: headers}) // stringify payload and post to server
      .map(res => res.json()) // .json() to return the data
      .catch(error => Observable.throw(error.json() || 'Server connection failed!')); // error handling<commit_msg>code refactoring<commit_after>import { Injectable } from '@angular/core';
import {Http} from "@angular/http";
import {Observable} from "rxjs/Observable";

/**
 * Custom Http handler
 * @author <NAME>
 * @class HttpClientService
 * @date June 2017
 */

@Injectable()
export class HttpClientService {

  constructor(private http: Http) { }

  /**
   * Custom post method to handle all Http POSTS in the app
   * @param url
   * @param data
   * @returns {Observable<R|T>}
   */
  public post(url, data, headers) {
    return this
      .http
      .post(url, JSON.stringify(data), {headers: headers}) // stringify payload and post to server
      .map(res => res.json()) // .json() to return the data
      .catch(error => Observable.throw(error.json() || 'Server connection failed!')); // error handling
{'fraction_non_alphanumeric': 0.14333556597454788, 'fraction_numerical': 0.0026791694574681848, 'mean_word_length': 3.5688073394495414, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6599607', 'n_tokens_mistral': 451, 'n_tokens_neox': 442, 'n_words': 144}