Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.onload = load;
- let refresh_token = '';
- function load() {
- $.ajax({
- method: 'POST',
- url: 'http://ignite.local/api/oauth/token',
- data: {
- username: 'admin@admin.com',
- password: 'secret',
- role: 1,
- },
- }).done(data => {
- refresh_token = data.refresh_token;
- getReport(data.access_token);
- });
- };
- function getReport(token) {
- $.ajax({
- method: 'GET',
- url: '/api/projects/1/candidates/1/report',
- headers: {
- Authorization: `Bearer ${token}`,
- Accept: 'application/json',
- },
- })
- .done(html => {
- document.write(html);
- })
- .fail(xhr => {
- console.log(`${xhr.status}: ${xhr.responseText}`);
- console.log(`from server: ${xhr.responseJSON.message}`);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement