0

I'm trying to http.get() request to node.js from angular in institute.ts.

import {Http} from "@angular/http";
export class InstituteListPage {
  data: any =[];
  constructor(private http:Http) {
  this.getData();
  }
getData(){
        let URL = "http//localhost:3005/institute";
        console.log(URL);
       this.http.get(URL).subscribe(data => { console.log("****************"   ,data)},
          err => {
            let alert = this.AlertC.create(
              {
                title:"ERROR",
                message:err,
                buttons: [
                  {
                    text:"OK",
                    role:"cancel"
                
                  }
                ]
              }
            );
            alert.present();
          })
          
  }
  }

When I run this code, I get

GET http://localhost:8100/http//localhost:3005/institute 404 (Not Found)

while the http post request works fine

How can I get it done?

2
  • May I suggest you to change the title of your question? Right know it is over-specific which may lead to this question being overlooked by those who could help. Commented Feb 1, 2019 at 1:56
  • try let URL = "http://localhost:3005/institute"; Commented Feb 1, 2019 at 4:42

1 Answer 1

1

Most likely the issue here is misspelled schema in your URL. It should be http:// otherwise this URL will be (and actually is) treated by Angular as a relative one

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.