Project

General

Profile

« Previous | Next » 

Revision 55906

[angular7 | Library]:
1. subscribe.service: Add return type <any> for post requests.
2. customOptions.class: In getAuthOptionsWithBody function change return type from any to {}.

View differences:

modules/uoa-services-library/branches/angular7/ng-openaire-library/src/app/services/servicesUtils/customOptions.class.ts
1
import { RequestOptions, Headers} from '@angular/http';
2
import { COOKIE  } from '../../login/utils/helper.class';
1
import {COOKIE} from '../../login/utils/helper.class';
3 2
import {HttpHeaders} from "@angular/common/http";
4 3

  
5 4

  
......
15 14
  }
16 15
  */
17 16

  
18
  public static getAuthOptionsWithBody():any {
19

  
20
    const httpOptions = {
17
  public static getAuthOptionsWithBody():{} {
18
    return {
21 19
      headers: new HttpHeaders({
22 20
        'Content-Type': 'application/json',
23 21
        'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id)
24 22
      }), withCredentials: true
25 23
    };
26
    return httpOptions;
27 24
  }
28 25

  
29 26
  /*
modules/uoa-services-library/branches/angular7/ng-openaire-library/src/app/utils/subscribe/subscribe.service.ts
12 12
  constructor(private http:HttpClient) {
13 13
    }
14 14
     getCommunitySubscribers(pid:string, url:string){
15
       return this.http.get(url+"/community/"+pid+"/subscribers");
15
       return this.http.get<any>(url+"/community/"+pid+"/subscribers");
16 16
                       //.map(res => <any> res.json());
17 17
     }
18 18

  
......
43 43
     }
44 44
     unSubscribeToCommunity(pid:string, email:string, url:string){
45 45

  
46
       return this.http.post(url+"/community/"+pid+"/subscribers/delete", JSON.stringify([email]), this.getAuthOptionsWithBody());
46
       return this.http.post<any>(url+"/community/"+pid+"/subscribers/delete", JSON.stringify([email]), this.getAuthOptionsWithBody());
47 47
           //.map(res => <any> res.json());
48 48
     }
49 49
     getCommunitiesSubscribedTo(email:string, url:string){
modules/uoa-services-library/branches/angular7/ng-openaire-library/src/app/claims/claimsByToken/claimsByToken.service.ts
1 1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Jsonp, URLSearchParams,ResponseOptions, RequestOptions, Headers} from '@angular/http';
4
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
5
import {Observable, throwError} from 'rxjs';
2
import {RequestOptions, Headers} from '@angular/http';
3
import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http";
4
import {throwError} from 'rxjs';
6 5

  
7 6

  
8 7
import { CustomOptions } from '../../services/servicesUtils/customOptions.class';
......
59 58

  
60 59
    let body = JSON.stringify( claimsCurationInfo );
61 60
    //console.warn('Json body:  : '+body);
62
    let headers = new Headers({ 'Content-Type': 'application/json' });
63
    let options = new RequestOptions({ headers: headers });
61

  
64 62
    return this.http.post(url, body,  CustomOptions.getAuthOptionsWithBody())
65 63
                          //.map(res => res.json())
66 64
                          //.do(request => console.info("Insert Response:"+request.status) )
......
76 74

  
77 75
      let body = JSON.stringify( claimsCurationInfo );
78 76
      //console.warn('Json body:  : '+body);
79
      let headers = new Headers({ 'Content-Type': 'application/json' });
80
      let options = new RequestOptions({ headers: headers });
77

  
81 78
      return this.http.post(url, body,  CustomOptions.getAuthOptionsWithBody())
82 79
                            //.map(res => res.json())
83 80
                            .pipe(catchError(this.handleError));

Also available in: Unified diff