Hello! I have a api rest made in codeigniter which brings me a get type query and wants it to be actialize in real time with Socket, try it and I get an error. If someone can help me I would be so thankful .
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { URL_SERVICIOS } from '../../config/url.servicios';
import { OnInit } from '@angular/core';
import * as io from 'socket.io-client';
@Injectable()
export class PedidosProvider {
pedidos:any[]=[];
socketHost:string='http://localhost:8100';
// socket: SocketIOClient.Socket;
socket:any;
constructor(public http: Http) {
this.socket = io.connect(this.socketHost);
this.socket.on('connect', () => {
this.datos_Pedidos();
});
console.log('Hello PedidosProvider Provider');
//
}
datos_Pedidos(){
let url= URL_SERVICIOS+"pedidos/pedido";
this.http.get(url).map(resp=> resp.json()).subscribe(data=> {
console.log(data);
if(data.error){
}else{
this.pedidos.push(...data.ordenes);
}
});
// this.socket.emit('new message', this.pedidos);
}
}
/*-->URL_SERVICIOS= http://maribelpata18.000webhostapp.com/index.php/<-- */
Is it possible not to use socket locally in ionic that works when the AAP is installed in the cell?