Advertisement
Guest User

Untitled

a guest
Oct 11th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. public static class WebApiConfig
  2. {
  3. public static void Register(HttpConfiguration config)
  4. {
  5. ...
  6.  
  7. var cors = new EnableCorsAttribute("*", "*", "*");
  8.  
  9. config.EnableCors(cors);
  10.  
  11. ...
  12.  
  13. }
  14. }
  15.  
  16. loginUser(username: string, password: string) {
  17. let serviceURL = 'http://myurl/token';
  18.  
  19. let body = 'username=' + username + '&password=' + password + '&grant_type=password';
  20.  
  21. let headers: Headers = new Headers();
  22. headers.append('Content-Type', 'application/x-www-form-urlencoded');
  23.  
  24. let options: RequestOptions = new RequestOptions({
  25. headers: headers
  26. });
  27.  
  28. return this.http.post(serviceURL, body, options)
  29. .map(res => this.extractData(res))
  30. .catch(this.handleError);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement