小编Man*_*dia的帖子

throw new ERR_INVALID_ARG_TYPE('chunk',['string','Buffer'],chunk);TypeError[ERR_INVALID_ARG_TYPE]:“chunk”参数必须是字符串或缓冲区类型

我正在尝试.json使用 node js 服务将文件的内容转换为 angularjs 方法。但我收到以下错误:

_http_outgoing.js:700 throw new ERR_INVALID_ARG_TYPE('chunk', ['string', 'Buffer'], chunk); ^ TypeError [ERR_INVALID_ARG_TYPE]:“chunk”参数必须是字符串或缓冲区类型之一。在 ServerResponse.end (_http_outgoing.js:700:13) 接收到类型对象

这是相应的代码片段...

角度控制器:注释行都是我尝试过但失败的行。

var currentProcess = "process_1cA";
$scope.storestats = [];
var resAss = $resource('/procs/getstorestats');
var stats = resAss.get({
  process: currentProcess,
  date: date.getFullYear() + "" + m + "" + d
});
stats.$promise.then(function(response) {
  if (response != undefined) {
    //    var r = JSON.parse(response);
    //$scope.storestats.push(r);
    //$scope.storestats.push(r);

    //var r = JSON.parse(response);
    $scope.storestats.push(response);
    //angular.forEach(r, function(value, key) {
    //    $scope.storestats.push({key : value}); …
Run Code Online (Sandbox Code Playgroud)

json node.js angularjs

7
推荐指数
2
解决办法
3万
查看次数

Angular 7:异步验证器更改检测

我编写了一个异步验证器来检查输入的电子邮件是否已存在于我的数据库中。

\n\n

我使用反应式表单 api 来构建我的表单,并将异步验证器配置为仅在“模糊”时触发。正如角度文档中提到的

\n\n

它运行良好:当我离开该字段时会触发验证,但直到我与表单交互时才会显示错误消息。

\n\n

如果我在验证中使用 setTimeout 函数手动触发changeDetection,它就会起作用。

\n\n

知道为什么验证完成后不直接显示此错误吗?

\n\n

这是我的表单定义:

\n\n
private initPersonalInformationFormGroup() {\n  this.personalInformationFormGroup = this._formBuilder.group({\n    lastName: [\'\', Validators.required],\n    firstName: [\'\', Validators.required],\n    gender: [Gender.MALE],\n    birthDate: [\'\'],\n    birthPlace: [\'\'],\n    nationality: [\'\'],\n    inss: [\'\', [Validators.minLength(11), Validators.maxLength(11), Validators.pattern(\'[0-9]{11}\')]],\n    email: [\'\', {\n      validators: [Validators.required, Validators.email],\n      asyncValidators: [this._studentEmailValidator()],\n      updateOn: \'blur\'\n    }],\n    phoneNumber: [null, Validators.pattern(\'\\\\+32[1-9][0-9]{7,8}\')],\n    address: this._formBuilder.group({\n      street: [\'\', [Validators.maxLength(60)]],\n      houseNumber: [\'\', [Validators.maxLength(10)]],\n      city: [\'\', [Validators.maxLength(60)]],\n      postalCode: [null, [Validators.min(1000), Validators.max(9999)]],\n    }, {\n      validators: this._completeAddressValidator()\n    }),\n    previousSchool: [\'\', Validators.maxLength(60)],\n    additionalInformation: …
Run Code Online (Sandbox Code Playgroud)

validation asynchronous angular

7
推荐指数
2
解决办法
4673
查看次数

在loopback应用程序中插入或更新(upsert)

我使用Loopback框架开发了一个API,因为我必须insert or update使用一个表.

我的表如下所示:

userid  bbid saved  id(PK)
  1      5    1000   1
Run Code Online (Sandbox Code Playgroud)

所以当下次if(bbid = 5)时它应该更新上面的行,如果没有bbid = 5那么它应该插入上面的表中.

我尝试了以下方法:

app.models.modelname.upsert({
  bbid: bb.id,
  saved: Saved,
  userid: 1
}, function(err, res) {}); 
Run Code Online (Sandbox Code Playgroud)

编辑COMPOSITE ID:

app.models.modelname.upsert({
  bbid: vvvv.bbid,
  userid: 1,
  saved: amountSaved
}, function(err, res) {});   
Run Code Online (Sandbox Code Playgroud)

它也说过了Loopback doc

    upsert - checks if the instance (record) exists, based on the designated 
ID property, which must have a unique value; if the instance already exists, 
the method updates that instance.  Otherwise, it inserts a …
Run Code Online (Sandbox Code Playgroud)

upsert node.js loopbackjs

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

数据路径“”不应具有附加属性(dryRun)

当我在终端中输入时,我在 MAC 中安装了最新的 Angular 6.0.4:

ng new happiness
Run Code Online (Sandbox Code Playgroud)

展示:

Schematic input does not validate against the Schema: {"dryRun":false,"version":"6.0.4","skipGit":false,"skipInstall":false,"linkCli":false,"commit":true,"newProjectRoot":"projects","inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","style":"css","skipTests":false} Errors:Data path "" should NOT have additional properties(dryRun).
Run Code Online (Sandbox Code Playgroud)

谁能告诉我?非常感谢

macos angular-cli angular

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

当尝试隧道localhost Web API时,serveo.net返回502,前端框架有角度

我有一个问题serveo.net

我正在尝试检查我在应用程序中引入的一些社交媒体元标记是否可以正常运行,现在我不希望在不确定结果的情况下完成PR。但是由于这些元标记只能在实时服务器上进行测试,因此我想到了隧道本地主机,然后使用https://opengraphcheck.com检查结果的想法

我的本地主机正在运行"localhost:4500",并且我在终端中使用以下命令"ssh -R 80:localhost:4500 serveo.net",这将返回一个URL,但是当我尝试导航到服务器提供的URL时,会收到一个

HTTP错误502。

这可能是什么原因?

我正在使用C#内置的后端WEP API项目和一个Angular前端项目。Angular Live Development Server正在监听localhost:4500

javascript tunnel angular

6
推荐指数
1
解决办法
176
查看次数

NodeJS(ExpressJS)未处理拒绝TypeError:回调不是函数

这几天我一直在学习使用Angular 6NodeJS(使用ExpressJS).为此,我决定使用Angular 6创建一个前端(其中包含一个表单),旨在通过使用我使用NodeJS创建的API 来回传递信息到我的PHPMyAdmin数据库.正如您在标题中看到的那样,当我尝试提交表单信息时出现以下错误:

" 未处理的拒绝TypeError:回调不是函数 "

我用于后期操作的代码来自另一个功能相似的API,数据库接收到question_id和user_id,但不会注册问题答案(这是最终目标).如果没有更多的东西,这里是获取和发布的代码:

const config = require('../config/config');
const knex      = config.db.knex;
const async     = require('async');


class TestModel {        
  getQuestions(callback) {
        knex('question')
        .select('id', 'libelle')
    .orderBy('id', 'asc')
        .then((data) => {
            callback(data);
        });
    }


  addResponse(reponse, callback) {
      knex('reponse')
      .insert({
          id_user : 1,
          id_question : reponse.id,
          libelle: reponse.answer,
      }).then((data) => {
          callback(data);
        });
  }        
}


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

其余部分如下:

app.post('/quiz', function(req, res, next){
    var answers = …
Run Code Online (Sandbox Code Playgroud)

javascript database node.js express angular

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

如何在golang中轻松编辑JSON类型(如Node.js)

我尝试将 node.js 代码转换为 golang 代码。

这是我的示例 JSON。

{
  "result": {
    "birthInfo": {
      "birthYmd": "2018-07-25",
      "cattleNo": "cow001",
      "docType": "registerBirth",
      "lsTypeNm": "redbull",
      "monthDiff": "2018-07",
      "nationNm": "japan",
      "regType": "directly",
      "regYmd": "2018-07-25",
      "sexNm": "farm001"
    },
    "breed": {
      "dead": {
        "deadCd": "deadcd20180725",
        "deadYmd": "2018-07-25",
        "docType": "reportDeCattle"
      },
      "earTag": {
        "docType": "reattachEartag",
        "flatEartagNo": "eartag206015",
        "rfidNo": "rfid234234"
      }
    }
  }
}  
Run Code Online (Sandbox Code Playgroud)

使用node.js时,可以很容易地获取或访问这样的json数据。

let cowbytes = await stub.getState("cow001");
var cowInfo = JSON.parse(cowbytes);

var eartag = {
  docType: 'reattachEartag',
  flatEartagNo: "eartag206015",
  rfidNo: "rfid234234",
};

if (cowInfo.breed) {
  cowInfo.breed['earTag'] = …
Run Code Online (Sandbox Code Playgroud)

json go node.js hyperledger-fabric

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

防止react-simple-maps中出现蓝色路径矩形

所以我使用react-simple-maps 来制作世界地图,但是当我单击地图时的默认行为是该国家/地区周围的蓝色矩形。preventDefault()我尝试在 an 上使用onClick,但这并不能消除它。有人对如何解决这个问题有任何想法吗?

这是我的代码。谢谢您的帮助!

import React, { Component } from "react"
import {
  ComposableMap,
  ZoomableGlobe,
  Geographies,
  Geography
} from "react-simple-maps"
import { Motion, spring } from "react-motion"

const mapStyles = {
  width: "90%",
  height: "auto"
}

class Map extends Component { 
  constructor(props) {
    super(props)

    this.handleClick = this.handleClick.bind(this)
  }

  handleClick(geography, evt) {
    evt.preventDefault()
}
  render() {
    return (
        <div>
    <Motion
      defaultStyle={{
        x: this.props.center[0],
        y: this.props.center[1]
      }}
      style={{
        x: spring(this.props.center[0]),
        y: spring(this.props.center[1])
      }}
    >
      {({ x, y …
Run Code Online (Sandbox Code Playgroud)

javascript node.js d3.js reactjs

5
推荐指数
2
解决办法
1404
查看次数

Angular Universal无法在路由器出口内呈现内容

我正在尝试通过此链接https://angular.io/guide/universal使用Angular Universal使用SSR渲染Angular 7应用程序。我以为我可以从那里开始一切工作,因为我能够查看页面源代码并看到呈现给页面的app.component内部的所有内容。但是,我无法在router-outlet标记内渲染任何路线

我只是简单地剥离了我的应用程序,以完全按照文档中的说明进行操作。我在其中读到了一些有关确保ModuleMapLoaderModule在app.server.module内部的内容,以便进行延迟加载。默认情况下,angular-cli命令会附带此命令,因此我不确定发生了什么。

app.server.module

import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader';

import { AppComponent } from './app.component';
import { AppModule } from './app.module';

@NgModule({
  imports: [
    AppModule,
    ServerModule,
    ModuleMapLoaderModule,
  ],
  bootstrap: [AppComponent],
})
export class AppServerModule {}
Run Code Online (Sandbox Code Playgroud)

tsconfig.server.json

  "extends": "./tsconfig.app.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app-server",
  },
  "angularCompilerOptions": {
    "entryModule": "app/app.server.module#AppServerModule"
  }
}
Run Code Online (Sandbox Code Playgroud)

server.ts

import 'zone.js/dist/zone-node';
import { enableProdMode } from '@angular/core';
// Express …
Run Code Online (Sandbox Code Playgroud)

universal angular-universal ssr angular angular7

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

使用 Loopback 4 发送电子邮件

我对 Loopback 和 Typescript 有点陌生,所以我不知道如何实现它。我试图直接调用 Nodemailer,但到目前为止我一直收到错误。

我的邮寄服务:

import { SentMessageInfo } from 'nodemailer';
import Mail = require('nodemailer/lib/mailer');
const nodemailer = require("nodemailer");

export class MailerService {
  async sendMail(mailOptions: Mail.Options): Promise<SentMessageInfo> {
    const transporter = nodemailer.createTransport({
      host: 'smtp.ethereal.email',
      port: 587,
      auth: {
        user: 'albert.grimes@ethereal.email',
        pass: 'qN85JT6SneBA9S5dhy'
      }
    });
    return await transporter.sendMail(mailOptions);
  }
}
Run Code Online (Sandbox Code Playgroud)

我的邮件控制器:

import { Request, RestBindings, get, ResponseObject } from 

'@loopback/rest';
import { inject } from '@loopback/context';
import { MailerService } from "../services";

export class MailController {
  constructor(
    @inject ??? …
Run Code Online (Sandbox Code Playgroud)

javascript loopback typescript strongloop loopback4

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