Created
August 17, 2020 16:44
-
-
Save ardiesaeidi/f27682bfc9ef47d5998cd623ef7ba503 to your computer and use it in GitHub Desktop.
using fetch api to make clientside requests
This file contains hidden or 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('/api/v1/clients', { | |
method: 'post', | |
headers: { | |
'accept': 'application/json', | |
'content-type': 'application/json', | |
'x-csrf-token': 'bJYS4JDu-mmYxfO4Vrnqb8vruIC8Hh-uAvzk' | |
}, | |
body: JSON.stringify({ "name": "test" }) | |
}).then(function(res) { | |
res.json().then(function(data) { | |
console.log(data); | |
}); | |
}) | |
fetch('/api/v1/clients', { | |
method: 'POST', | |
headers: { | |
'accept': 'application/json' | |
}, | |
body: JSON.stringify({ "name": "test" }) | |
}).then(function(res) { | |
res.json().then(function(data) { | |
console.log(data); | |
}); | |
}) | |
fetch('/api/v1/clients', { | |
method: 'post', | |
headers: { | |
'accept': 'application/json', | |
'content-type': 'application/json', | |
'x-csrf-token': '6v0vDFuc-lpc3-s2zSXGXoHCJ0qTDA0pyox8', | |
'host': 'evil.com' | |
}, | |
body: JSON.stringify({ "name": "test" }) | |
}).then(function(res) { | |
res.json().then(function(data) { | |
console.log(data); | |
}); | |
}) | |
fetch('/api/v1/Clients') | |
.then(function(res) { | |
res.json().then(function(data) { | |
console.log(data); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment