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 is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                    <div class="wrapper">
        <div class="field">
          <label for="url">URL для запроса</label><br>
          <input type="text" value="" id="url" name="url" placeholder="Введите URL" />
        <div class="group">
          <div class="field">
            <label for="method">Метод</label><br>
            <select id="method">
              <option value="POST">POST</option>
              <option value="GET">GET</option>
              <option value="PUT">PUT</option>
              <option value="OPTIONS">OPTIONS</option>
          <div class="field">
            <label for="mode">CORS mode</label><br>
            <select id="mode">
              <option value="no-cors">'no-cors' игнорируем cors</option>
              <option value="cors">'cors' кроссдомен по умолчанию</option>
              <option value="same-origin">'same-origin' только на свой домен</option>
        <div class="field">
          <label for="reqhead">Заголовки запроса</label><br>
          <textarea rows="5" cols="30" id="reqhead">{
  "Accept": "application/json",
  "Content-Type": "application/json"
        <div class="field">
          <label for="reqbody">Тело запроса</label><br>
          <textarea rows="5" cols="30" id="reqbody">{
  "id": 123456,
  "title": "заголовок"
        <div class="field">
          <button type="button" id="send">Отправить</button>
      <div id="result" class="result"></div>



                      html,body {
        font-family: monospace;
        box-sizing: border-box;
      .wrapper, .group {
        display: flex;
      .field {
        margin: 10px 5px;
      input, textarea {
        width: 100%;
      label + br {
        display: none;
      label {
        display: block;
      .result {
        padding: 5px;
        overflow: auto;
      .error {
        background-color: rgba(255,0,0,.1);
      .success {
        background-color: rgba(0,255,0,.1);



                      (function () {
        var url = document.querySelector('#url');
        var send = document.querySelector('#send');
        var result = document.querySelector('#result');
        var reqhead = document.querySelector('#reqhead');
        var reqbody = document.querySelector('#reqbody');
        var method = document.querySelector('#method');
        var mode = document.querySelector('#mode');

        function sendmessage() {
          result.innerHTML = 'Loading...';
          var urlValue = url.value.trim();
          if(!urlValue) {
            alert('Введите URL!');
            result.innerHTML = '';
          var headersValue = reqhead.value.replace(/(\r\n|\n|\r|\t)/gm, "").trim();
          if (headersValue) {
            try {
              headersValue = JSON.parse(headersValue);
            } catch(e){
              alert('В заголовках некорректный JSON!');
          } else {
            headersValue = {};

          var bodyValue = reqbody.value.replace(/(\r\n|\n|\r|\t)/gm, "").trim();
          bodyValue = bodyValue || {};

          var reqParams = {
            mode: mode.options[mode.selectedIndex].value,
            method: method.options[method.selectedIndex].value,
            body: bodyValue,
            headers: headersValue


          var myRequest = new Request(urlValue, reqParams);

          try {
              .then(function (resp) {
                var resultVal = '<p><b>Response:</b></p><p>' +
                'body: ' + resp.body + '<br>' +
                'bodyUsed' + resp.bodyUsed + '<br>' +
                'headers' + resp.headers + '<br>' +
                'ok' + resp.ok + '<br>' +
                'redirected' + resp.redirected + '<br>' +
                'status' + resp.status + '<br>' +
                'statusText' + resp.statusText + '<br>' +
                'type' + resp.type + '<br>' +
                'url' + resp.url + '</p>' +
                '<p>See console for details...</p>';
                result.innerHTML = '<div class="success">' + resultVal + '</div>';
              }).catch(function (err) {
                result.innerHTML = '<div class="error">' + err + ' <p>See console for details...</p></div>';
          } catch (e) {
            result.innerHTML = '<div class="error">' + e + ' <p>See console for details...</p></div>';


        send.addEventListener('click', sendmessage, false);