Dark Sky

FREEMIUM
Verified
(Ким) Dark Sky | Оновлено vor 4 Tagen | Weather
Популярність

0.5 / 10

Затримки

9ms

Рівень обслуговування

0%

Health Check

N/A

Повернутися до всіх обговорень

Getting a bad request error

Rapid account: Paulmcd 3
paulmcd3
vor 3 Jahren

I’m trying to use the forecast endpoint to get data but I am getting a bad request error as a response, I saw that when testing the endpoint on the site that two requests are sent, an options request and a get request but I am unsure on ho to make that work

This is part of my Angular service which makes the request, at the bottom there is my attempt at the preflight request but I am unfamiliar with making those types of requests:

lat:number = 53.05;
long:number = -9.77;
res:any;
private myDataUri = https://dark-sky.p.rapidapi.com/lat=${this.lat},long=${this.long};
httpOptions =
{
headers: new HttpHeaders({
“x-rapidapi-key”: “0115b0a18emsh48238943bae0b20p10c463jsn0d97c23f57ae”,
“x-rapidapi-host”: “dark-sky.p.rapidapi.com”,
“Access-Control-Request-Method”: “GET”})
};

ApiKey:string = ‘0115b0a18emsh48238943bae0b20p10c463jsn0d97c23f57ae’;

constructor(private http:HttpClient) { }
getForecast(): Observable<IWeather>
{
console.log(“get forecast called” );

  return this.http.get<IWeather>(this.myDataUri,this.httpOptions)
  .pipe(
    catchError(this.handleError)
  );

}

PrefilghtReq()
{
return this.http.options<any>(this.myDataUri,this.httpOptions)
.pipe(
catchError(this.handleError)
);

}

Any pointers on getting a correct response would be greatly appreciated.

Rapid account: Gurmolsofly 12
gurmolsofly12 Commented vor einem Jahr

I am also having the same problem testing for the time, it wont even work with the endpoint

Приєднуйтесь до обговорення — додайте повідомлення нижче:

Вхід / Реєстрація, щоб публікувати нові повідомлення