Skip to content

Instantly share code, notes, and snippets.

@dave-kennedy
Created August 5, 2017 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dave-kennedy/0de7d528f55ff3733b4a457218c8d6f3 to your computer and use it in GitHub Desktop.
Save dave-kennedy/0de7d528f55ff3733b4a457218c8d6f3 to your computer and use it in GitHub Desktop.
API request builder
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form>
<p>
<label>
URL: <input name="url">
</label>
</p>
<p>
Headers: <input type="button" id="add-header" value="Add">
</p>
<div id="headers"></div>
<p>
<input type="submit" value="Submit">
</p>
</form>
<script>
(function () {
var addHeaderBtn = document.getElementById('add-header'),
headers = document.getElementById('headers');
function addHeader() {
var row, key, value;
row = document.createElement('p');
key = document.createElement('input');
value = document.createElement('input');
key.name = 'headerKeys[]';
key.placeholder = 'Key';
value.name = 'headerValues[]';
value.placeholder = 'Value';
row.appendChild(key);
row.appendChild(value);
headers.appendChild(row);
}
addHeaderBtn.addEventListener('click', addHeader);
}());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment