I’m having an issue trying to connect my Angular app to a SQL Server on a remote server. The issue is that the HTTP server is refusing the connection, but I have checked the server (firewall, etc) and the server is configured properly for the connection. The following is the code I’m using:
type import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { firstValueFrom } from 'rxjs';
@Component({
selector: 'app-formulario',
templateUrl: './formulario.component.html',
styleUrls: ['./formulario.component.css']
})
export class FormularioComponent {
staticData = {
nombre: 'Ejemplo',
apellido: 'Ejemplo',
usuario: 'ejemplo',
terminal: 'ejemplo',
departamento: 'ejemplo'
};
constructor(private http: HttpClient) {}
guardar() {
console.log('presionaste el puto boton pinche menso')
try {
firstValueFrom(this.http.post('http://192.168.255.88:3000/guardar', this.staticData));
console.log('Información guardada correctamente');
} catch (error) {
console.error('Error al guardar la información:', error);
}
}
// async guardar(): Promise<void> {
// const data = {
// nombre: this.nombre,
// apellido: this.apellido,
// usuario: this.usuario,
// terminal: this.terminal,
// departamento: this.departamento
// };
// try {
// await firstValueFrom(this.http.post('http://192.168.255.88:3000/guardar', this.staticData));
// console.log('Información guardada correctamente');
// } catch (error) {
// console.error('Error al guardar la información:', error);
// }
// }
}
I’m getting the following error:
POST http://192.168.255.88:3000/guardar net::ERR_CONNECTION_REFUSED
I have already enabled CORS and I’m using Node.js as a server on port 3000, but I’m still not sure what the issue is. Please help!