angular - Type 'URLSearchParams' is not assignable to type 'URLSearchParams' -


i want send http.get request search parameters webapi list of students. found examples on how this, after doing in examples, weird error:

[ts] type 'urlsearchparams' not assignable type 'urlsearchparams'. 2 different types name exist, unrelated. property 'rawparams' missing in type 'urlsearchparams'. 

here's component:

import { injectable } '@angular/core'; import { http, headers, response, requestoptions } '@angular/http'; import 'rxjs/add/operator/map' import { user } '../_models/user';  @injectable() export class userservice {  options = new requestoptions({ 'headers': new headers({ 'content-type': 'application/json' })});  constructor(private http: http) { }  createaccount(newuser: user){ return this.http.post('http://localhost:64792/api/students', json.stringify(newuser), this.options) .map((response: response) => {                   if(response.ok){         console.log("registration success");         return true;      } else {          console.log("registration failed");          return false;       }  }); }  searchstudents(searchwords: array<string>){ // parameters obj-  let params: urlsearchparams = new urlsearchparams();  for(let = 0; < searchwords.length; i++){  params.append('searchwords', searchwords[i]);  }  this.options.search = params;  //http request- } }  

what causing error?

it seems native urlsearchparams declared present code, whereas new urlsearchparams(); returns angular.io's urlsearchparams object

import 'rxjs/add/operator/map' , should work.

import { urlsearchparams } '@angular/http'; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -