-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.min.html
1 lines (1 loc) · 1.36 KB
/
debug.min.html
1
<html><head> <title>API Debugger</title> <style>.center{text-align: center; margin-left: auto; margin-right: auto; margin-top: 100px;}textarea{width: 600px; height: 450px; font-size: 18px;}input{height: 30px; width: 1200px; font-size: 15px;}button{font-size: 20px; margin-top: 10px;}</style></head><body> <div class="center"> <h1>API-Debugger</h1> <div> <input id="url" placeholder="/api"/> <br><br></div><div> <textarea id="body" placeholder="Body"></textarea> <textarea id="response" placeholder="Response"></textarea> </div><div> <button onclick="submit('GET')">GET</button> <button onclick="submit('POST')">POST</button> <button onclick="submit('PUT')">PUT</button> <button onclick="submit('DELETE')">DELETE</button> </div><div> <button onclick="toJSON()">Beauty-JSON</button> </div></div></body></html><script>function submit(method){var http=new XMLHttpRequest(); http.open(method, document.getElementById('url').value, true); http.onreadystatechange=function(){if(http.readyState==4){if(http.status==200 | http.status==201 | http.status==202){document.getElementById('response').value=http.responseText;}else{document.getElementById('response').value="Error: " + http.status;}}}http.send(document.getElementById('body').value);}function toJSON(){document.getElementById('response').value=JSON.stringify(JSON.parse(document.getElementById('response').value), null, '\t');}</script>