Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
Angular 2 http.get

I am doing the following get in Angular 2 and I am getting a runtime exception:

http.get('http://localhost/MyCart/Home/GetProducts').subscribe(result => {
    this.categories = result.json().Data as any[];
    this.LoadDictionary();
    window.console.log(this.categories);
});

Is that the correct syntax? What am I doing wrong? If I delete the http.get, application is fine.

EDIT:

The error is below. Keep in mind I am using Angular's SPA template for .NET Core.

An unhandled exception occurred while processing the request. Exception: Call to Node module failed with error: ReferenceError: window is not defined at C:\Users\samir\Desktop\angular-core new\ClientApp\dist\main-server.js:269:13 at SafeSubscriber.schedulerFn [as _next] (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:3774:40) at SafeSubscriber.module.exports.SafeSubscriber.__tryOrUnsub (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:23052:16) at SafeSubscriber.module.exports.SafeSubscriber.next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:23001:22) at Subscriber.module.exports.Subscriber._next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:22943:26) at Subscriber.module.exports.Subscriber.next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:22907:18) at EventEmitter.module.exports.Subject.next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:68525:25) at Object.next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:90000:21) at SafeSubscriber.schedulerFn [as _next] (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:3762:56) at SafeSubscriber.module.exports.SafeSubscriber.__tryOrUnsub (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:23052:16) at SafeSubscriber.module.exports.SafeSubscriber.next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:23001:22) at Subscriber.module.exports.Subscriber._next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:22943:26) at Subscriber.module.exports.Subscriber.next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:22907:18) at EventEmitter.module.exports.Subject.next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:68525:25) at Object.next (C:\Users\samir\Desktop\angular-core new\ClientApp\dist\vendor.js:90000:21)

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

window.console.log(this.categories);

should be

console.log(this.categories);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!