Open vignestion opened 8 years ago
Is this a bug or My mistake I don't know what's going on Just trying to add test values to database App.js
import React from 'react'; import Horizon from '@horizon/client'; const horizon = Horizon({authType: "unauthenticated"}); const test = horizon('test'); export default class Home extends React.Component{ componentDidMount(){ horizon.onReady(function () { console.log('iam') }); horizon.connect(); let message = { text: "What a beautiful horizon!", datetime: new Date(), author: "@dalanmiller" }; test.store(message) } render(){ return( <div> This is Login </div> ) } }
import React from 'react'; import Horizon from '@horizon/client'; const horizon = Horizon({authType: "unauthenticated"}); const test = horizon('test');
export default class Home extends React.Component{ componentDidMount(){ horizon.onReady(function () { console.log('iam') }); horizon.connect(); let message = { text: "What a beautiful horizon!", datetime: new Date(), author: "@dalanmiller" }; test.store(message)
} render(){ return( <div> This is Login </div> ) }
}
server.js
const express = require('express'); const https = require('https'); const path = require('path'); const fs = require('fs'); const horizon = require('@horizon/server'); const app = express(); // Serve our static stuff like css app.use(express.static(path.join(__dirname, 'dist'))); // Send all requests to index.html app.get('*', function (req, res) { res.sendFile(path.join(dirname, 'dist', 'index.html')); }); const options = { key: fs.readFileSync(path.resolve(dirname, './horizon-key.pem')), cert: fs.readFileSync(path.resolve(__dirname, './horizon-cert.pem')), }; const PORT = 8181; const server = https.createServer(options, app); server.listen(PORT, function() { console.log('Express server running at localhost:' + PORT); }); const horizon_options = { project_name: 'react_horizon', permissions: true, auth: { token_secret: 'sd', allow_anonymous: true, allow_unauthenticated: true, } }; const horizon_server = horizon(server, horizon_options);
const express = require('express'); const https = require('https'); const path = require('path'); const fs = require('fs'); const horizon = require('@horizon/server');
const app = express();
// Serve our static stuff like css app.use(express.static(path.join(__dirname, 'dist')));
// Send all requests to index.html app.get('*', function (req, res) { res.sendFile(path.join(dirname, 'dist', 'index.html')); }); const options = { key: fs.readFileSync(path.resolve(dirname, './horizon-key.pem')), cert: fs.readFileSync(path.resolve(__dirname, './horizon-cert.pem')), };
const PORT = 8181;
const server = https.createServer(options, app);
server.listen(PORT, function() { console.log('Express server running at localhost:' + PORT); });
const horizon_options = { project_name: 'react_horizon', permissions: true,
auth: { token_secret: 'sd', allow_anonymous: true, allow_unauthenticated: true, }
}; const horizon_server = horizon(server, horizon_options);
Set permissions to false, then you don't have to care if operation is permitted or not
Is this a bug or My mistake I don't know what's going on Just trying to add test values to database App.js
server.js