node.js - migrering från angular 5 till angular 7
Igår har jag migrerat min applikation från Angular 5 till Angular 7. I den processen har jag ändrat EventSource till EventSourcePolyfill som föreslagits när jag körde applikationen. Men sedan dess har jag stött på ett konstigt problem. Detta är vad jag får för problem i konsolen som följer:
ERROR TypeError: Cannot read property 'heartbeatTimeout' of undefined
at new EventSourcePolyfill (eventsource.js:155)
at AppFooterComponent.push../src/app/layout/footer/footer.component.ts.AppFooterComponent.connect (footer.component.ts:133)
at SafeSubscriber._next (footer.component.ts:52)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:196)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next (Subscriber.js:134)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next (Subscriber.js:77)
at Subscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
at AsyncAction.dispatch (timer.js:31)
at AsyncAction.push../node_modules/rxjs/_esm5/internal/scheduler/AsyncAction.js.AsyncAction._execute (AsyncAction.js:63)
at AsyncAction.push../node_modules/rxjs/_esm5/internal/scheduler/AsyncAction.js.AsyncAction.execute (AsyncAction.js:51)
Detta är vad jag gjorde i min kod:
import { EventSourcePolyfill } from 'ng-event-source';
let source = new EventSourcePolyfill('/api/v1/events/register');
Kan någon föreslå hur jag kan bli av med detta problem.
Tack.
Svar #1
Du måste skicka ytterligare parametrar, eftersom
eventSource = new EventSourcePolyfill(url,
{ heartbeatTimeout: 5000, connectionTimeout: 5000, headers: { 'Authorization': 'Basic foo' }});
