小编Ped*_*les的帖子

POST请求后执行模块

我正在尝试通过套接字(使用socket.io)集成发送实时信息,并使用OneSignal平台发送推送通知.

碰巧的是,如果我把所有东西放在同一个模块中,我不知道为什么在发送信息之后或发送信息之前不会执行发送通知的方法.

如果我运行命令npm start没有出现错误,但是一旦本地或远程服务器运行,通知就会到达,这样我就不希望它发生了.

user.js的

  var express = require('express');
var router = express.Router();
var misocket = require('../routes/misocket');
var notificacion = require('../routes/notificacion');

/*

run module when start server run, i don't want it

notificacion();

*/ 

/* GET users listing. sendnote*/
router.post('/sendasig', function(req, res, next) { 


    console.log(misocket);//registrednote
    misocket.emit("registrar",req.body);  
  //run here, after the send data across post request
  notificacion();
    console.log(req.body);

  res.status(200).json({
      message  : "send message"
  }); 

});

module.exports = router;
Run Code Online (Sandbox Code Playgroud)

notificacion.js

 module.exports = function(){ 

        var OnesignalNotificationApi = require('onesignal-notification');
        var …
Run Code Online (Sandbox Code Playgroud)

javascript push-notification node.js express

5
推荐指数
1
解决办法
567
查看次数

警告:React.createElement:type无效 - bundle.js

我正在学习React JS的教程,一切都很好,几天我可以运行一个例子,简单,执行推荐的基本配置,再添加一些我添加的附加组件来识别Javascript版本.

几天不再审查项目,但它正常工作,执行命令时,我没有看到任何错误,但它没有在浏览器中显示任何内容,只有多个错误出现在这个控制台中.

我已经卸载并重新安装了reac和react-dom,问题仍然存在,尝试从朋友那里克隆它的新项目,它正常工作,它只复制了我的相同结构.

问题

警告:React.createElement:type无效 - 期望一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:undefined.您可能忘记从其定义的文件中导出组件,或者您可能混淆了默认导入和命名导入.

上述错误发生在您的某个React组件中:考虑向树中添加错误边界以自​​定义错误处理行为.

应该注意,错误出现在文件中bundle.js,用于存储生成的代码webpack

errores

树

的package.json

{
  "name": "prueba",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node server.js",
    "dev": "concurrently \"node server.js\" \"webpack -w\" "
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.16.2",
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "serve-static": "^1.13.1"
  },
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "concurrently": "^3.5.1",
    "eslint": "^4.9.0",
    "eslint-config-airbnb-base": "^12.1.0",
    "eslint-plugin-import": "^2.7.0",
    "webpack": "^3.10.0"
  }
}
Run Code Online (Sandbox Code Playgroud)

webpack.config.js

const path = require('path'); …
Run Code Online (Sandbox Code Playgroud)

javascript node.js reactjs webpack react-dom

5
推荐指数
1
解决办法
1万
查看次数

SignalR:连接尚未完全初始化.使用.start().done()或.start().fail()在连接启动后运行逻辑

试图复制一个例子我遇到了没有建立连接的问题,当涉及到从服务器到我的计算机时,但是当我在远程工作时它是否正常工作.

链接示例

链接1 链接2

这是我的代码

var app = angular.module('app', []);
app.value('$', $);

app.factory('signalRSvc', function ($, $rootScope) {
    return {
        proxy: null,
        initialize: function (acceptGreetCallback) {           

            //Getting the connection object
            connection = $.hubConnection('http://190.109.185.138:8016');         

            //Creating proxy
            this.proxy = connection.createHubProxy('HelloWorldHub');

            //Starting connection
            connection.start({ jsonp: true }).done(function () {
                alert("funciono");
            });

            connection.start({ jsonp: true }).fail(function () {
                alert("fallo");
            });

            //connection.start({ jsonp: true }).done(function () {
            //    console.log("connection started!");
            //});  


            //Attaching a callback to handle acceptGreet client call
            this.proxy.on('acceptGreet', function (message) {
                $rootScope.$apply(function () { …
Run Code Online (Sandbox Code Playgroud)

javascript c# signalr angularjs

3
推荐指数
1
解决办法
4145
查看次数