ff-stream-web

git clone git://archive.git.mtrnord.blog/MTRNord/ff-stream-web.git
Log | Files | Refs | README | LICENSE

index.js (993B)


      1 /**
      2  * React Starter Kit (https://www.reactstarterkit.com/)
      3  *
      4  * Copyright © 2014-present Kriasoft, LLC. All rights reserved.
      5  *
      6  * This source code is licensed under the MIT license found in the
      7  * LICENSE.txt file in the root directory of this source tree.
      8  */
      9 
     10 import React from 'react';
     11 import Home from './Home';
     12 import fetch from '../../core/fetch';
     13 import Layout from '../../components/Layout';
     14 
     15 export default {
     16 
     17   path: '/',
     18 
     19   async action() {
     20     const resp = await fetch('/graphql', {
     21       method: 'post',
     22       headers: {
     23         Accept: 'application/json',
     24         'Content-Type': 'application/json',
     25       },
     26       body: JSON.stringify({
     27         query: '{news{title,link,content}}',
     28       }),
     29       credentials: 'include',
     30     });
     31     const { data } = await resp.json();
     32     if (!data || !data.news) throw new Error('Failed to load the news feed.');
     33     return {
     34       title: 'Freifunk Streaming',
     35       component: <Layout><Home news={data.news} /></Layout>,
     36     };
     37   },
     38 
     39 };