在模式文件中添加一个字段给出和错误,同时执行该文件

嗨,这是我已经有的模式文件。 // defining a mongoose schema // including the module var mongoose = require('mongoose'); // declare schema object. var Schema = mongoose.Schema; var blogSchema = new Schema({ title : {type:String,default:'',required:true }, subTitle : {type:String,default:''}, blogBody : {type:String,default:''}, tags : [],// name of tags in array created : {type:Date}, lastModified : {type:Date}, authorInfo : {} // […]

如何将sails集成到现有的快速nodejs应用程序中

我有一个现有的快速服务器设置,我想尝试将sails合并到它使用它提供的MVC结构。 这可能吗?

在localhost:3000上启动npm后,控制台显示错误

在localhost:3000上单击npm start后,我在控制台日志中收到以下错误 不能GET / @angular度/平台浏览器dynamic 不能GET / @angular度/平台浏览器dynamic npm版本3.10.9节点版本v7.2.0 package.json如下 { "name": "angular-quickstart", "version": "1.0.0", "description": "QuickStart package.json from the documentation, supplemented with testing support", "scripts": { "build": "tsc -p src/", "build:watch": "tsc -p src/ -w", "build:e2e": "tsc -p e2e/", "serve": "lite-server -c=bs-config.json", "serve:e2e": "lite-server -c=bs-config.e2e.json", "prestart": "npm run build", "start": "concurrently \"npm run build:watch\" […]

解决 – 如何使用内容types:应用程序/ JSON,与节点JS上的请求+ restfulapi

如何理解内容typesaplication / json的内容,如果我有restful api模块,并且在节点服务器上请求 var request = require('request'); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); request({ url: 'http://localhost/4000/notes/12vdsgte5657', method: 'POST', json: {mes_id: '12vdsgte5657'} }, function(error, response, body){ console.log(body); }); 这在API路由器上 module.exports = function(app, db) { var ObjectID = require('mongodb').ObjectID; app.get('/notes/:id', (req, res) => { //const id = req.params.id; console.log(req.body,id) console.log(req.params.id,new ObjectID(id)) const details = { '_id': new […]

在node.js中检索JSON数据时出错

我试图做一个Android应用程序,显示我的AWS ec2实例上的顶部命令数据。 以下是我写的node.js文件。 它使用topparser npm模块发送最高命令结果。 并且使用checkCpuUsage函数,如果cpu使用率大于1%,它会发送一个通知。 var express = require('express'); var app = express(); var fs = require('fs'); var spawn = require('child_process').spawn; var topparser=require("topparser"); var FCM = require('fcm-node'); var server = app.listen(8080); var regTokens = []; var bodyParser = require('body-parser'); app.use(bodyParser.json()); let data_builder = ""; const DEFAUT_TOP_DURATION = 2000; function getTopData(callback, duration) { duration = […]

我正在使用来自NPM的unsplash-js api

我在我的反应项目中使用了unsplash-js,当我使用search查询获取一些随机照片时,我在下面的JSON检查中得到了返回结果。 {total: 303, total_pages: 31, results: Array(10)} results:Array(10)0:{id:“nitdfruLYys”,created_at:“2016-10-12T13:04:23-04:00”,updated_at:“2017-08-02T04:08:11-04:00” ,width:4000,height:6000,…} 1:{id:“XE87arvN3oo”,created_at:“2015-12-12T11:43:35-05:00”,updated_at:“2017-08-02T12:08:22 -04:00“,width:4272,height:2848,…} 2:{id:”iS0Aq3QPsJ4“,created_at:”2016-02-26T19:51:15-05:00“,updated_at:”2017-08- 02T16:36:55-04:00“,width:3000,height:1691,…} 3:{id:”41eXcLghVhI“,created_at:”2017-07-15T20:50:43-04:00“,updated_at: 4:{id:“EjlygRQAOik”,created_at:“2017-02-07T19:59:18-05: 00“,updated_at:”2017-08-02T00:30:17-04:00“,width:5000,height:3333,…} 5:{id:”WicMLrOSVvY“,created_at:”2015-10-24T13:40 :06-04:00“,updated_at:”2017-07-31T07:00:30-04:00“,width:3456,height:2304,…} 6:{id:”Fu8pblIzEL0“,created_at: 03-06T16:49:09-05:00“,updated_at:”2017-08-01T20:41:35-04:00“,width:4928,height:3264,…} 7:{id:”D9XX 3Cjoh2s“,created_at:”2016-02-21T15:45:25-05:00“,updated_at:”2017-08-02T20:44:56-04:00“,width:6000,height:4000,…} 8 :{id:“Aka2x2D4Ph0”,created_at:“2016-01-21T03:42:02-05:00”,updated_at:“2017-07-28T10:24:12-04:00”,width:5616,height: 3744,…} 9:{id:“E-1tnSNP0y4”,created_at:“2015-11-08T19:32:31-05:00”,updated_at:“2017-07-30T17:19:06-04:00” ,width:5472,height:3648,…} length:10 proto :Array(0)total:303 total_pages:31 proto :Object 我需要设置这个状态作为一个数组,但是当我在我的代码中设置我得到这个错误:对象是无效的作为一个React的孩子 this.setState({photos:json});

在Chrome中发生Sequelize查询和PUT错误

学生问题! 我正在学习使用Sequelize ORM的Node.js / Express和MySQL数据库。 传统上,在我们简单的应用程序中,在使用Sequelize查询MySQL数据库之后,我们将在Express PUT路由中发出res.redirect('/') ,然后类似如下: app.post("/", function (req, res) { db.Burgers.create({ burger_name: req.body.burger_name }).then(function () { res.redirect('/'); }); }); 当使用findOrCreate()方法创build一个sequelize查询时,我遇到了一个问题。 也就是说,我正在努力寻找将res.redirect语句放在AJAX PUT请求上的位置。 出于某种原因,当我在PUT语句的快速path中附加了res.redirect('/')时,Chromenetworking检查器中将看到重复的PUT请求。 第一个PUT请求显示为(localhost:3000 / devour,input:text / plain,status:302)。 Express服务器接收到PUT请求,并且继续查询成功,更新MySQL数据库中正确的表。 但是,Express路由redirect不成功,Chrome Inpector显示错误“PUT http:// localhost: 3000/404(Not Found)”,当我看到networking选项卡时,我看到第二个PUT请求(localhost: 3000 /,input:xhr,status:404)。 这是Express PUT路线: app.put("/devour", function (req, res) { var customerId; // Check to see if the […]

Nodejs网站在后台执行

所以我正在开发一个基于Nodejs的通话logging网站,当我logging通话时,我已经到了需要发送短信给工程师的地步。 我有访问的短信网关本质上是一个URL如下: http://192.xxx username = x password = y&to = mobileno &text = xyz 我的要求是执行此链接,以便短信发送和页面保持原样,而不必redirect。 非常感谢

使用angular2 +服务编辑对象,mongoDB和NodeJs

我想对存储在数据库(mongoDB)中的数据进行基本编辑。 这是我所做的: angular度服务 createReview(review) { let headers = new Headers(); headers.append('Content-Type', 'application/json'); this.http.post('http://localhost:3000/api/reviews', JSON.stringify(review), { headers: headers }) .subscribe(res => { console.log(res.json()); }); } editReview(review) { let headers = new Headers(); headers.append('Content-Type', 'application/json'); this.http.post('http://localhost:3000/api/reviews', JSON.stringify(review), { headers: headers }) .subscribe(res => { console.log(res.json()); }); } deleteReview(id){ this.http.delete('http://localhost:3000/api/reviews/' + id).subscribe((res) => { console.log(res.json()); }); } 在server.js中 […]

如何使用js将大量事务发送到ethereum

我试图用一个用js编写的程序向Ethereum发送大量事务。 我使用节点js,web3和infura ropsten。 问题是:如果我一次发送交易,他们中的大多数就会消失。 试图解决这个问题,我发送间隔交易。 它工作,但非常缓慢。 我花了小时只发送100笔交易。 有没有解决scheme如何使其工作更快,更正确? 我想在前一个开始挂起之后发送交易,但我不知道该怎么做。 函数sendRaw只在一段时间后才获取交易号。 该代码读取文件,获取地址,金额和可选数据,并使用智能合约的方法转移令牌。 这是代码: function sendRaw(rawTx) { var privateKey = new Buffer(key, 'hex'); var transaction = new tx(rawTx); transaction.sign(privateKey); var serializedTx = transaction.serialize().toString('hex'); web3.eth.sendRawTransaction( '0x' + serializedTx, function(err, result) { if(err) { console.log(err); } else { console.log(result); Ntrans=result; } }); } var nonce = web3.eth.getTransactionCount(address); var gasPrice […]