Tag: node.js

如何导出asynchronous函数?

以下是我的代码 – abc.js class abc { async foo1() { // do something return result; } async foo2() { // do something return result; } module.exports = abc } 另外,file.js const abc = requir(./abc); abc.foo1(); // this results in error // TypeError : abc.foo1 is not a function 我应该怎么做?

节点js适合于批量更新

我在节点上写了一个脚本来与2个系统连接,并使用api将一堆更新应用到一个。 使用个别的例子更新工作正常,但是当把它们放在一起我得到一个超时错误。 由于节点的非阻塞性质而导致的猜测,即使用数千次更新来洪泛系统可能是问题。 我是否选错了使用的工具/引擎? 如果是的话,我的path是什么样的阻力最小(是否有其他的JavaScript环境,我可以重新使用我的代码?或者有没有办法设置某种深度的队列,以保持传出请求的数量没有响应较低)

Node.js中的模型文件不会考虑configuration

我有这样的模型文件,如下所示: 'use strict' module.exports = function (sequelize, DataTypes) { let User = sequelize.define('user', { id: { type: DataTypes.INTEGER(11), allowNull: false, primaryKey: true, autoIncrement: true } }, { classMethods: { associate: function(models) { this.belongsToMany(models.role, { through: { model: 'user_role' }, foreignKey: 'user_id' }) } } }, { tableName: 'user', timestamps: false, underscored: true } ) return […]

keystone.Storage适配器谷歌云存储

是否有一个谷歌云存储适配器keystone.Storage库? 我想承载一切我可以与一个服务提供商。 我将使用谷歌云平台来托pipe我的Keystone.js应用程序和MongoDB数据库。 该库有本地文件,S3和Azure适配器,但我不知道如何使用它与谷歌云存储。 请参阅https://github.com/keystonejs/keystone/tree/master/lib/storage 如果可以像keystone-storage-adapter-s3一样使用,我会很棒: configuration: var storage = new keystone.Storage({ adapter: require('keystone-storage-adapter-gcloud'), s3: { key: 'gcloud-key', secret: 'secret', bucket: 'mybucket', path: '/profilepics', headers: {}, }, schema: { bucket: true, etag: true, path: true, url: true, }, }); 然后用它作为File域的存储提供者: File.add({ name: { type: String }, file: { type: Types.File, storage: storage }, });

React defaultValue不工作axios传递dynamic数据

你好即时新在React和即时通讯尝试玩一点与反应,但inheritance人一点我不明白。 首先,获取axios数据谁返回我的数据,下面,然后我尝试把它们放入input字段,值(和只读),defaultValue更好,现在我有问题,我什么都看不到,值存在当我用萤火虫查看时,奇怪的是,当我添加一个不需要的字符input得到我想要的填充,但不是默认情况下。 非常奇怪的是,当我把所有东西放在一个数组中,并且在它上面执行一个映射函数时,我有这个值 json代码 {"firma":"hallo","strasse":"musterweg 7","plz":"01662"} js代码 import React from 'react'; import ReactDOM from 'react-dom'; import axios from 'axios'; class Testx extends React.Component { constructor(props) { super(props); this.state = { data:[] }; } componentDidMount(){ var self = this; axios.get('http://localhost/index.php') .then(function (response) { self.setState({ data: response.data}); }) .catch(function (error) { console.log(error); }); } render() { return […]

运行npm run build vue后,某些图片没有被加载

我完成了我的Vue应用程序,并运行npm run build部署应用程序。 一切似乎都很好。 但是,我的一些图片将无法运行。 我的四个图像渲染得很好。 但是,这四个图像不在我的img文件夹中。 在控制台上,我得到这个错误: GET file:///C:/static/img/Two.550dff0.jpeg net::ERR_FILE_NOT_FOUND 图像名称是“Two.550dff0.jpeg”,它位于img文件夹中,但应用程序无法访问它。 这是为什么? 而且,对于渲染的四个图像,这些图像不在img文件夹中。 我也无法在dist文件夹中find这四个图像。 这是index.HTML代码: <script type=text/javascript src=static/js/manifest.1f30a815db1d214533a9.js></script> <script type=text/javascript src=static/js/vendor.0757592c5dae8c3165a1.js></script> <script type=text/javascript src=static/js/app.53c259c8c3df1ec9179f.js></script>

在文件资源pipe理器中无法打开子目录? – Node.js

我不明白为什么我不能在Node.js中打开“我的文档”的子目录。 我目前的代码: function fileExplorer() { var spawn = require('child_process').spawn, child = spawn('C:\\Windows\\explorer.exe', ["%userprofile%\\documents"]); } 完全正常工作来启动用户的“我的文档”文件夹。 但是,如果我想在“我的文档”里面打开一个目录,比如说“我的文档/附加资料”,以下是不起作用的: function fileExplorer() { var spawn = require('child_process').spawn, child = spawn('C:\\Windows\\explorer.exe', ["%userprofile%\\documents\\extra stuff"]); } 我错过了什么? 请原谅我,如果我问的是什么问题,我有一个devise导向的大脑,更熟悉HTML,CSS和一些Javascript。

节点OracleDB错误:无法find指定的过程

使用OracleDB时出错Error“指定的程序找不到”.Node安装OracleDB经历的很好。 为构build执行的步骤是 已安装Visual Studio 2017 Visual C ++ 14.0 下载并遵循oracle即时客户端和sdk,添加了OCI_BIN和OCI_INC npm安装npm @ latest npm install node-gyp -g(在这之前删除了c:\ users \ .node-gyp npm安装oracledb OCI_INC_DIR指向“C:\ Oracle \ instantclient \ lib \ msvc” OCI_LIB_DIR指向'C:\ Oracle \ instantclient \ include'npm done的用于oracledb@1.13.1 运行具有node app.js /app.js内容的代码时出错 var oracle = require("oracledb"); console.log(oracle) Windows 8.1 x64 64 Bit OS gyp info using node-gyp@3.6.2 gyp […]

Express正在发送一个对象,里面有一个对象

我有一个连接到Mongoose数据库的Express服务器(我的术语可能不正确,因为我刚开始学习Express)。 当我访问一个/pipe理员(路线?)我收到一个对象与我的JSON对象里面。 我发错了吗? var userSchema = new Schema({ firstName: {type: String, trim: true}, lastName: {type: String, trim: true}, classYear: Number, email: {type: String, unique: true, sparse: true, trim: true}, phone: {type: String, unique: true, sparse: true}, phoneProvider: {type: String, trim: true}, isAdmin: {type: Boolean, index: true}, isSuperAdmin: {type: Boolean, index: true}, hash: String, companyName: {type: […]

将$ ajax转换为PUT请求的提取()

我试图翻译下面的jQuery代码来使用抓取API。 它发出一个PUT请求: function save () { $.ajax('/{{user.username}}', { method: 'PUT', data: { street: $('#street').val(), city: $('#city').val(), state: $('#state').val(), zip: $('#zip').val() }, complete: function () { cancel() location.reload() } }) } 这是抓取API请求: fetch('/{{user.username}}', { method: 'PUT', headers: { 'Content-Type': 'application.json' }, body: JSON.stringify({ street: document.getElementById("street").value, city: document.getElementById("city").value, state: document.getElementById("state").value, zip: document.getElementById("zip").value }) }).then(() => { cancel() […]