Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
"Los parámetros proporcionados no coinciden con ninguna firma del destino de la llamada". mientras usa un get para recopilar información de la API

Recibo este error y soy nuevo en angular 2, por lo que no estoy 100% seguro de cómo resolver el problema, me estoy conectando a una API de prueba para devolver un objeto javascript que incluye algunos datos ficticios. Pero mi función "this.onGet()" me dice que el parámetro proporcionado no coincide con ninguna firma del destino de la llamada y parece que no puedo entender por qué. (Esencialmente, solo estoy tratando de completar la matriz orderInfo con la información de la API para poder usarla en varias páginas)

Cualquier ayuda apreciada :)

App.component.ts

 import { Component, OnInit } from '@angular/core'; import { DetailsService } from './details.service'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], providers: [DetailsService] }) export class AppComponent implements OnInit { orderInfo = [ { name: 'Test' } ]; constructor(private detailsService: DetailsService) { } ngOnInit() { this.onGet(); } onGet(name: string) { this.detailsService.getDetails() .subscribe( (orderData: any[]) => { this.orderInfo.push({ name: name }); console.log(orderData); } ); } }

detalles.servicio.ts

 import {Injectable} from '@angular/core'; import { Http, Response } from '@angular/http'; import 'rxjs/Rx'; @Injectable() export class DetailsService { constructor(private http: Http) {} getDetails() { return this.http.get('http://swapi.co/api/people/1/?format=json', '') .map( (response: Response) => { const orderData = response.json(); return orderData; } ); } }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

La firma del método http get es

 get(url: string, options?: RequestOptionsArgs) : Observable<Response>

Estás pasando un parámetro de cadena adicional

 getDetails() { ///////////////removed below single quotes return this.http.get('http://swapi.co/api/people/1/?format=json') .map( (response: Response) => { const orderData = response.json(); return orderData; } );

mira en tu

 ngOnInit() { this.onGet(); //////////nothing passed }

donde, como la firma de su método es onGet(name:string) , no está pasando nada como arriba

over 4 years ago · Santiago Trujillo Report

0

Su función OnGet espera un parámetro de cadena, que no se proporciona al llamar desde ngOnInit.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!