Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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.


                <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"POST", proxyURL);
    // open and send request
  $submit.addEventListener("click", submitRequest);
})(window, document);