0
我是一個反應和cassandra newwbie。我只是想用「npm i cassandra-driver」連接到cassandra db。Cassandra與反應,net.socket錯誤
我有一個main.js文件,我使用cassandra驅動程序代碼。
Main.js
import 'babel-polyfill';
import 'whatwg-fetch';
import React from 'react';
import ReactDOM from 'react-dom';
import FastClick from 'fastclick';
import { Provider } from 'react-redux';
import store from './core/store';
import router from './core/router';
import history from './core/history';
const cassandra = require('cassandra-driver');
const client = new cassandra.Client({ contactPoints: ['127.0.0.1'], keyspace: 'excelsior'});
console.log("client---->",client);
const query = 'SELECT * FROM playlists';
client.execute(query, [], function(err, result) {
console.log("err----->",err);
console.log("result----->",result);
assert.ifError(err);
//console.log('got user profile with email ' + result.rows[0].email);
});
let routes = require('./routes.json'); // Loaded with utils/routes-loader.js
const container = document.getElementById('container');
function renderComponent(component) {
ReactDOM.render(<Provider store={store}>{component}</Provider>, container);
}
// Find and render a web page matching the current URL path,
// if such page is not found then render an error page (see routes.json, core/router.js)
function render(location) {
router.resolve(routes, location)
.then(renderComponent)
.catch(error => router.resolve(routes, { ...location, error }).then(renderComponent));
}
continued code ......
我收到客戶端控制檯,但在那之後我得到了如下的錯誤
connection.js:122 Uncaught TypeError: net.Socket is not a constructor(…)
我在這裏失去了一些東西。或者這段代碼應該寫在其他地方。 ?
由於
你是否試圖在客戶端代碼(即瀏覽器)中運行它?我問,因爲使用react/redux /等。在那裏常用。 –
@LukeTillman:是的...或者與我一起如何連接這個? – Krishna