css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <section class="bcls-section" id="ajax">
  <h2>API tester</h2>

  <p>This test sends an API GET request to the proxy via AJAX</p>

  <div class="form-wrapper">
      <legend>Tester for Brightcove APIs</legend>

      <p>Client id: <input id="client_id" type="text" placeholder="your client id" name="client_id" /></p>

      <p>Client secret: <input id="client_secret" type="text" placeholder="your client secret" name="client_secret" /></p>

      <p>Call type: <select name="requestType" id="requestType"><option selected="selected">GET</option><option>POST</option><option>PUT</option><option>PATCH</option><option>DELETE</option></select></p>

      <p>Full request URL for the API call:<br />
        <textarea name="url" id="url" class="bcls-code"></textarea></p>

      <p>Call body (optional - include if you need to submit data with the request):<br />
        <textarea name="requestBody" id="requestBody" class="bcls-code"></textarea></p>

      <p><input id="submit" class="bcls-button" type="submit" value="Submit" /></p>


<code id="response">results will go here</code></pre>
              /* * The body style is just for the
 * background color of the codepen.
 * Do not include in your code.
body {
  background-color: #111;
  color: #f5f5f5;
  font-family: sans-serif;
  margin: 2em;
 * Styles essential to the sample
 * are below
.bcls-code {
  color: #111;
  font-family: 'Source Code Pro',monospace;
  padding: 1em;
  width: 90%;
  min-height: 5em;
  background-color: #cfcfcf;
  font-size: 1rem;
.bcls-button {
  padding: .5em;
  background-color: #333;
  border: 1px yellow solid;
  border-radius: .5em;
  color: yellow;
  cursor: pointer;
fieldset {
  color: #64AAB2;
  border: 1px #64AAB2 solid;
  border-radius: .5em;
code {
  color: #E4B842;
  font-family: 'Source Code Pro',monospace;
              var BCLS = (function (window, document) {
  var $client_id = document.getElementById("client_id"),
    $client_secret = document.getElementById("client_secret"),
    $requestBody = document.getElementById("requestBody"),
    $requestType = document.getElementById("requestType"),
    $url = document.getElementById("url"),
    $submit = document.getElementById("submit"),
    $response = document.getElementById("response");

  // is defined
  function isDefined(x) {
    if (x === "" || x === null || x === undefined) {
      return false;
    return true;
  // function to remove spaces and line breaks
  function cleanString(str) {
    if (str !== "") {
      // remove line breaks
      str = str.replace(/(\r\n|\n|\r)/gm, "");
      // remove spaces
      // here we have to be careful - spaces fine within strings
      // but not outside them
      str = JSON.stringify(JSON.parse(str));
      return str;
    } else {
       * tests to see if a string is json
       * @param {String} str string to test
       * @return {Boolean}
  function isJson(str) {
    try {
    } catch (e) {
      return false;
    return true;
  // function to submit Request
  submitRequest = function () {
    var httpRequest = new XMLHttpRequest(),
      proxyURL =
      options = {};
    if (isDefined($client_id.value) && isDefined($client_secret.value)) {
      options.client_id = $client_id.value;
      options.client_secret = $client_secret.value;
    if (isDefined($requestBody.value)) {
      options.requestBody = cleanString($requestBody.value);
    options.requestType = $requestType.value;
    options.url = $url.value;
    console.log("options", options);
    getResponse = function () {
      try {
        if (httpRequest.readyState === 4) {
          if (httpRequest.status >= 200 && httpRequest.status < 300) {
            console.log("response", httpRequest.responseText);
            if (isJson(httpRequest.responseText)) {
              parsedData = JSON.parse(httpRequest.responseText);
              $response.textContent = JSON.stringify(parsedData, null, "  ");
            } else {
              $response.textContent = httpRequest.responseText;
          } else {
              "There was a problem with the request. Request returned " +
      } catch (e) {
        alert("Caught Exception: " + e);
    // set response handler
    httpRequest.onreadystatechange = getResponse;
    // open the request
    httpRequest.open("POST", proxyURL);
    // open and send request
  $submit.addEventListener("click", submitRequest);
})(window, document);

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................