找不到HTTPS Params Angle 7错误404

时间:2019-05-06 05:41:18

标签: angular http parameters header angular-httpclient

我在这里想念什么?没有找回正确的网址,未正确显示经纬度,我收到404 not found错误。

import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';

import { Observable } from 'rxjs';
import * as constants from '../../src/app/constants/constants';



@Injectable()


export class ForecastService {

   url = `https://cors-anywhere.herokuapp.com/https://api.darksky.net/forecast/${constants.DARKSKY_API_KEY}/`;

  constructor(private http: HttpClient) {}


  getForecastData(lat: number, lng: number): Observable<any>  {
    let params = new HttpParams()
    params = params.set('lat', lat.toString() )
    params = params.set('lng', lng.toString() )
    console.log(lat,lng)

    return this.http.get(this.url, {params:params})


  }
}

我得到的是错误: HttpErrorResponse {标题:HttpHeaders,状态:404,statusText:“未找到”,网址:“ cors-anywhere.herokuapp.com / https://api.da……2823eaa6089 /?lat = 52.025137099999995&lng = 5.0709602” –

0 个答案:

没有答案