Its now 8 hours trying to solve a trivial issue & I can't believe it !
here below a script of angular service
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable({
  providedIn: 'root'
})
export class GetStockDataService {
  constructor(public http:HttpClient) { }
  RequestData={"query":"{\n  stock{\n    history{\n      \n      low\n      high\n      demand\n    }\n  }\n}"}
getstockdata(){
  return this.http.post('http://localhost:3000/',this.RequestData)
}
}
and here is a component script which is calling that service
import { Component, OnInit } from '@angular/core';
import { GetStockDataService } from '../services/get-stock-data.service';
import { Platform } from '@ionic/angular';
@Component({
  selector: 'app-Stocks',
  templateUrl: 'Stocks.page.html',
  styleUrls: ['Stocks.page.scss']
})
export class StocksPage implements OnInit {
  constructor(private GetStockData:GetStockDataService , private platform : Platform) {}
  res:any
  ngOnInit(){
    this.getdata().subscribe(data=>{this.res=data});
    console.log(this.res)
  }
  getdata(){
    return this.GetStockData.getstockdata() }}   
WHY the "res" variable is always returning NULL ???? knowing that when I put the console log the variable inside there in the function in the subscription part .. it returns data but I can't make this variable global ... how could I do that ? I just want to get the data from the subscription to the "res" variable to use it the HTML file later .
 
    