Created
June 9, 2017 11:34
-
-
Save zhanhongtao/3a86471d59e48266dc55c253ab3a7331 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>cross</title> | |
</head> | |
<body> | |
<script> | |
document.cookie = 'a=aaa' | |
fetch('http://example.com/data/data.json?type=normal').then(res => { | |
return res.json() | |
}).then(res => { | |
console.log('normal:', res) | |
}) | |
// Credentials | |
fetch('http://example.com/data/data.json?type=cookie', { | |
credentials: 'include' | |
}).then(res => { | |
return res.json() | |
}).then(res => { | |
console.log('credentials:', res) | |
}) | |
// header | |
fetch('http://example.com/data/data.json?type=header', { | |
headers: { | |
'Content-Type': 'application/json' | |
} | |
}).then(res => { | |
return res.json() | |
}).then(res => { | |
console.log('header:', res) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment