12335

Angular 2 login not working in safari and firefox

Question:

For some reason the login part of my application is not working on safari and firefox.

I get this error while trying to auth. <a href="https://i.stack.imgur.com/Hi97I.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/Hi97I.png" data-original="https://i.stack.imgur.com/Hi97I.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

Now the code is working perfectly in chrome.

Signin Service.ts

import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { Http, Headers, RequestOptions } from '@angular/http'; import { HttpWrapper } from '../../../shared/services/http-wrapper.service'; import { SERVER_URL } from '../../../shared/config/config'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; @Injectable() export class SigninService { constructor( private http_native: Http, private http: HttpWrapper ) { }; public login(user: { email: string, password: string }): Observable<any> { let headers = new Headers({ 'Content-Type': 'application/json' }); headers.append('Accept', 'application/json;q=0.9,*/*;q=0.8') let options = new RequestOptions({ headers: headers }); return this.http_native.post(`${SERVER_URL}users/login`, JSON.stringify(user), options) .catch((error: any) => { return Observable.throw(error); }) .map((response: Response) => { return response.json(); }) };

SinginComponent.ts

public login($event): void { $event.preventDefault(); if (this.signinForm.valid) { this.signinFormIsValid = true; let { email, password } = this.signinForm.value; this.signinService.login({ email, password }) .subscribe((response: any) => { console.log('response', response); sessionStorage.setItem('user', JSON.stringify(response)); this.loginDispatcherService.setUser(response); this.availableParties = response.associatedPartyIds; this.tokenId = response.authenticationTokenId; this.stepOne = false; this.stepTwo = true; }); } else { this.signinFormIsValid = false; } };

Any suggestions are welcomed.

Answer1:

you need to upgrade the es6-shim.<br /> check this -> <a href="https://www.npmjs.com/package/es6-shim" rel="nofollow">https://www.npmjs.com/package/es6-shim</a>

Answer2:

Safari and Firefox require the es6-shim as described in the Mandatory Polyfills section of <a href="https://angular.io/guide/browser-support#core-es6" rel="nofollow">the docs</a>.

Follow these steps to fix your issue:

<ol><li>Run npm install --save es6-shim</li> <li>Edit your polyfills.ts file, adding import 'es6-shim' on a new line.</li> </ol>

Build your application and it should now work.

Recommend

  • Comparing elements in two lists when keeping duplicates is desired in Python
  • Javascript NULL Values
  • Is it possible to utilize $addToSet multiple times in the same update?
  • How to avoid multiple definition of function (Linux, GCC/G++, Code::Blocks)
  • How to get list of users who's birthday is today in MongoDB
  • Update SQL MS Access 2010
  • std::system Exception when instantiating a singleton object
  • Type safe keys with Entity Framework model
  • Haskell: function composition with anonymous/lambda function
  • How to concat Pandas dataframe columns
  • Why isn't my “Fizz Buzz” test in R working?
  • Criterion causing memory consumption to explode, no CAFs in sight
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • RxJava debounce by arbitrary value
  • How can I set a binding to a Combox in a UserControl?
  • Create DicomImage from scratch using Dcmtk
  • How do I access an unhandled exception in an MVC Error view?
  • Email verification using google app script and google forms
  • Email format validation in mvc3 view
  • sending/ receiving email in Java
  • How to model a transition system with SPIN
  • Javascript + PHP Encryption with pidCrypt
  • AT Commands to Send SMS not working in Windows 8.1
  • Cannot Parse HTML Data Using Android / JSOUP
  • Python: how to group similar lists together in a list of lists?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • JTable with a ScrollPane misbehaving
  • Angular 2 constructor injection vs direct access
  • Getting Messege Twice Using IMvxMessenger
  • Authorize attributes not working in MVC 4
  • apache spark aggregate function using min value
  • unknown Exception android
  • Django query for large number of relationships
  • Busy indicator not showing up in wpf window [duplicate]
  • Sorting a 2D array using the second column C++
  • How can i traverse a binary tree from right to left in java?
  • failed to connect to specific WiFi in android programmatically
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF
  • How can I use threading to 'tick' a timer to be accessed by other threads?