0

I want to make a get request from my component. I am currently making it inside componentWillMount method. So this component is the second page of application. First page is the login page. When I click on the login button on the first page then this page comes. I am getting the error while making the GET request. Here is how I am making the request

 componentWillMount = ()=> {
        var settings = {
            "async": true,
            "crossDomain": true,
            "url": "https://api/v1/workgroups/",
            "method": "GET",
            "headers": {
                Authorization: "Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"
            },
            success: function( data, textStatus, jQxhr ){
                alert("success");
            },
        }

        $.ajax(settings).done((response) => {
            alert("yo");
            console.log('check');
            // this.context.router.push('/app')
        });
    }

Here are images of network and console tabs

enter image description here

enter image description here

enter image description here

EdG
  • 2,243
  • 6
  • 48
  • 103

1 Answers1

3

The error message says that name resolution failed, so your system doesn't know how to convert api to an ip address.

You can either:

  • Change the hostname in the URL to one which resolves
  • Fix your DNS so it supports that hostname
  • Patch around DNS locally by editing your system's hosts file
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • can you please tell me how to do any of these things – EdG Jan 18 '17 at 15:15
  • @ApurvG — Place the cursor after `https://api`, press the backspace key on your keyboard three times, then type the real name of your server. – Quentin Jan 18 '17 at 15:19
  • can you please tell me what do you mean by real name of my server? – EdG Jan 18 '17 at 15:40
  • You are trying to send a message over a network to a computer. Computers on a network are identified by IP addresses. Hostnames are human-friendly names so that you don't have to remember the numbers that make up the IP address. You need to put the name of the computer you are trying to send the message to. The error message implies that `api` is not the right name. – Quentin Jan 18 '17 at 15:43