Get request giving errors

41 Views Asked by At

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

1

There are 1 best solutions below

4
On BEST ANSWER

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