Last active
April 19, 2018 12:21
-
-
Save alastair38/9ea87f2a70f433cb6d18e7e5228e0a08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch("https:.....", { // url used is QA endpoint supplied (excluded here for security reasons) | |
method: "GET", | |
headers: { | |
"Authorization": "Basic c3ltcGxlY3RpY1BTWUNISUFUUlk6YnJpZ2h0Ymx1ZXN0YWdl" //encoded username:password | |
} | |
}).then( | |
function(response) { | |
if (response.status !== 200) { | |
console.log('Looks like there was a problem. Status Code: ' + | |
response.status); | |
return; | |
} | |
// Examine the text in the response | |
response.json().then(function(data) { | |
console.log(data); | |
}); | |
} | |
) | |
.catch(function(err) { | |
console.log('Fetch Error :-S', err); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$URL='https:....'; // url used is QA endpoint supplied (excluded here for security reasons) | |
$headers = array( | |
'Authorization: Basic c3ltcGxlY3RpY1BTWUNISUFUUlk6YnJpZ2h0Ymx1ZXN0YWdl' //encoded username:password | |
); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
curl_setopt($ch, CURLOPT_URL,$URL); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 60); //timeout after 30 seconds | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false); // also tried with TRUE | |
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code | |
if (!curl_errno($ch)) { | |
$info = curl_getinfo($ch); | |
print_r($info); | |
} else { | |
print curl_error($ch); | |
} | |
$result=curl_exec ($ch); | |
print($result); | |
curl_close ($ch); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
type: 'GET', | |
url: 'https:....', // url used is QA endpoint supplied (excluded here for security reasons) | |
headers: { | |
"Authorization": "Basic c3ltcGxlY3RpY1BTWUNISUFUUlk6YnJpZ2h0Ymx1ZXN0YWdl", //encoded username:password | |
}, | |
success: function(data) { | |
/* handle data here */ | |
console.log(data); | |
}, | |
error: function(xhr, status) { | |
/* handle error here */ | |
console.log(status); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment