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

404
Views
Failed to execute 'open' on 'XMLHttpRequest': Invalid URL

I got run time error:

Failed to execute 'open' on 'XMLHttpRequest': Invalid URL Error: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL at http://localhost:8100/build/polyfills.js:3:2793 at XMLHttpRequest.open (eval at s (http://localhost:8100/build/polyfills.js:2:29793), :3:31)

import { Injectable } from '@angular/core';
import { Http, Headers } from '@angular/http';
import 'rxjs/add/operator/map';

@Injectable()
export class Reviews {


  data: any;

  constructor(public http: Http) {
    this.data = null;
  }

  getReviews(){

    if (this.data) {
      return Promise.resolve(this.data);
    }

    return new Promise(resolve => {

      this.http.get('http://localhost:app/api/reviews')
        .map(res => res.json())
        .subscribe(data => {
          this.data = data;
          resolve(this.data);
        });
    });

  }

  createReview(review){

    let headers = new Headers();
    headers.append('Content-Type', 'application/json');

    this.http.post('http://localhost:app/api/reviews', JSON.stringify(review), {headers: headers})
      .subscribe(res => {
        console.log(res.json());
      });

  }

  deleteReview(id){

    this.http.delete('http://localhost:app/api/reviews/' + id).subscribe((res) => {
      console.log(res.json());
    });    

  }

}
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

http://localhost:app/api/reviews

This is an invalid URL (just like the error message says).

If you have a : after the hostname, it must be followed by a port NUMBER (and then the path). app is not a number, it is three letters.

over 4 years ago · Santiago Trujillo Report

0

The problem is with your URL. Read the error message properly it's saying invalid URL

Here you are using localhost:app in your URL 'http://localhost:app/api/reviews' which is incorrect. You have to use some kind of open port number instead of random text. For example 3000, 4000, 5000, 8080, 8000, etc.

So your URL will be like this 'http://localhost:3000/api/reviews'

over 4 years ago · Santiago Trujillo Report

0

In my case, i'm facing the same problem in reactjs. I found that there was as typo in endpoint(http://:ip). so after correcting that. issue resolved

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!