Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


  <link rel="stylesheet" href="">
    <title>Sending a POST request</title>
    <div class="container">
      <header id="page-header" class="bg-dark text-white col-sm-12">
        <h1 id="main-heading" class="text-center">Sending a POST request</h1>
      <div class="row">
        <main class="col-sm-10 offset-sm-1">
            <div class="form-group">
              <label for="title">Title</label>
              <input type="text" id="title" class="form-control" required>
            <div class="form-group">
              <label for="content">Content</label>
              <textarea id="content" class="form-control" rows="4" required></textarea>
            <button id="submit-button" type="submit" class="btn btn-primary">
      <div class="row">
        <section class="col-sm-10 offset-sm-1">
          <p id="response-message"></p>
          <h2 id="response-title"></h2>
          <small id="response-id"></small>
          <p id="response-content"></p>
    <script src="scripts.js"></script>




                // Get form elements
const titleInput = document.getElementById('title');
const contentInput = document.getElementById('content');
const submitButton = document.getElementById('submit-button');

const url = '';

// Get DOM elements for showing response
const responseMessage = document.getElementById('response-message');
const responseTitle = document.getElementById('response-title');
const responseId = document.getElementById('response-id');
const responseContent = document.getElementById('response-content');

submitButton.addEventListener('click', ($event) => {
  const post = {
    title: titleInput.value,
    content: contentInput.value

function makeRequest(data) {
  return new Promise((resolve, reject) => {
    let request = new XMLHttpRequest();'POST', url + '/create-post');
    request.onreadystatechange = () => {
      if (request.readyState === 4) {
        if (request.status === 201) {
        } else {
    request.setRequestHeader('Content-Type', 'application/json');