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.


Auto Save

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="container" id="app">
  <h3 class="text-center">VueNews</h3>

  <section class="callout secondary">
    <h5 class="text-center">Filter by Category</h5>
      <div class="row">
        <div class="large-6 columns">
          <select v-model="section">
							<option v-for="section in sections" :value="section">{{ section }}</option>
        <div class="large-6 columns">
          <a @click="getPosts(section)" class="button expanded">Retrieve</a>

  <h5 class="text-center uppercase" v-if="!loading">{{ title }}</b></h5>
  <div v-if="loading" class="loader"><img src="" alt="loader"></div>

  <news-list v-if="!loading" :results="results"></news-list>


                .container {
  padding: 20px 0

.columns:last-child:not(:first-child) {
  float: left;

.main_heading {
  margin: 10px 0 30px;

.callout {
  margin-bottom: 40px;

select {
  text-transform: capitalize;

.loader {
  text-align: center;
  padding: 40px;

.uppercase {
  text-transform: uppercase;


                const NYTBaseUrl = "";
const ApiKey = "your_api_key_here"; // replace with NYT API key 
const SECTIONS = "home, arts, automobiles, books, business, fashion, food, health, insider, magazine, movies, national, nyregion, obituaries, opinion, politics, realestate, science, sports, sundayreview, technology, theater, tmagazine, travel, upshot, world";

function buildUrl(url) {
  return '';

Vue.component('news-list', {
  props: ['results'],
  template: `
      <div class="row" v-for="posts in processedPosts">
        <div class="columns large-3 medium-6" v-for="post in posts">
          <div class="card">
          <div class="card-divider">
          {{ post.title }}
          <a :href="post.url" target="_blank"><img :src="post.image_url"></a>
          <div class="card-section">
            <p>{{ post.abstract }}</p>
  computed: {
    processedPosts() {
      let posts = this.results;

      // Add image_url attribute => {
        let imgObj = post.multimedia.find(media => media.format === "superJumbo");
        post.image_url = imgObj ? imgObj.url : "";

      // Put Array into Chunks
      let i, j, chunkedArray = [],
        chunk = 4;
      for (i = 0, j = 0; i < posts.length; i += chunk, j++) {
        chunkedArray[j] = posts.slice(i, i + chunk);
      return chunkedArray;

const vm = new Vue({
  el: '#app',
  data: {
    results: [],
    sections: SECTIONS.split(', '), // create an array of the sections
    section: 'home', // set default section to 'home'
    loading: true,
    title: ''
  mounted() {
  methods: {
    getPosts(section) {
      let url = buildUrl(section);
      axios.get(url).then((response) => {
        this.loading = false;
        this.results =;
        let title = this.section !== 'home' ? "Top stories in '" + this.section + "' today" : "Top stories today";
        this.title = title + "(" + + ")";
      }).catch((error) => {