小编Ash*_*Jha的帖子

如何在"请求"npm包中设置内容类型

我从节点服务器发送请求到其他服务器,但我需要发送内容类型

应用程序/ JSON

我怎么发送,我使用这种格式

request.post('https://server.com/index.php/rest/V1/integration/admin/token',{form:postData},function (error, response, body) {
    console.log('error:', error); // Print the error if one occurred
    console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
    console.log('body:', body); // Print the HTML for the Google homepage.
    res.json({
        'error': error,
        'statusCode': response && response.statusCode,
        'body': body
    })
});
Run Code Online (Sandbox Code Playgroud)

我在尝试这个时遇到错误

 request.post(
        'https://server.com/index.php/rest/V1/integration/admin/token',
        {
            form:postData,
            headers:{ 
                "Content-Type": "application/json"
            }

    },function (error, response, body) {
        console.log('error:', error); // Print the error if one occurred
        console.log('statusCode:', response && …
Run Code Online (Sandbox Code Playgroud)

javascript request node.js

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

如何将材质2对话框Angular 2中的数据从1个组件发送到另一个组件

我正在使用Material 2 diloge,我能够获得关于diloge的数据.

但是我无法找到任何使用@input在diloge上发送数据的解决方案

import {Component} from '@angular/core';
import {MdDialog, MdDialogRef} from '@angular/material';

@Component({
  selector: 'dialog-result-example',
  templateUrl: './dialog-result-example.html',
})
export class DialogResultExample {
  selectedOption: string;

  constructor(public dialog: MdDialog) {}

  openDialog() {
    let dialogRef = this.dialog.open(DialogResultExampleDialog);
    dialogRef.afterClosed().subscribe(result => {
      this.selectedOption = result;
    });
  }
}

@Component({
  selector: 'dialog-result-example-dialog',
  templateUrl: './dialog-result-example-dialog.html',
})
export class DialogResultExampleDialog {
  constructor(public dialogRef: MdDialogRef<DialogResultExampleDialog>) {}
}
Run Code Online (Sandbox Code Playgroud)

angular-material2 angular

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

如何在 express-validator 中检查变量是 0 还是 1

我需要检查 req.body.isIssueFixed 是 0 还是 1 ,我正在 epress-validator 中尝试

req.checkBody(isIssueFixed , 'isIssueFixed  is not a boolean value ').isBoolean();
Run Code Online (Sandbox Code Playgroud)

但 isBoolean 不是方法。如何解决这个问题以及我可以在哪里检查 express-validator 的所有可用方法?

express

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

如何深入地映射对象

我想在我的所有对象值中改变一些东西,比如说

var a = {a:{c:1},b:2};
desire output :  a = {a:{c:5},b:10} //multiply by 5
Run Code Online (Sandbox Code Playgroud)

我这样做

 var m = function n (o){
    return Object.keys(o).map(function(v,i){
        if(o[v] !== null && typeof o[v] === 'object') return n(o[v])
        else return (o[v]*5);
    })
    }

a = m({a:{c:1},b:2})
Run Code Online (Sandbox Code Playgroud)

但得到一个输出

[
  [
    5
  ],
  10
]
Run Code Online (Sandbox Code Playgroud)

javascript object

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

"在一个框架中,因为它将'X-Frame-Options'设置为'sameorigin'." 在节点APP中

我有一个节点应用程序,在域和子域上运行.

示例:

abc.com - >主服务器

abc.com/admin - >管理面板

a.abc.com - >用户门户网站

b.abc.com - >另一个用户门户网站

现在我需要在I帧内的" abc.com "中使用" a.abc.com " .如果我使用

a.abc.com/admin

这也打开管理门户然后我能够看到

a.abc.com

在iframe但如果我登录

abc.com/admin

并在iframe中尝试a.abc.comb.abc.com它会出错

拒绝在框架中显示" http://a.abc.com ",因为它将"X-Frame-Options"设置为"sameorigin".

如何允许这个.我正在使用node/express.

iframe cross-domain node.js express

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

Angular CLI项目不使用IP地址运行

Angular CLI项目在

localhost:4200 
Run Code Online (Sandbox Code Playgroud)

但它不能在(我的本地主机)上运行

10.0.0.30:4200
Run Code Online (Sandbox Code Playgroud)

如何使用IP地址运行它,以便我也可以在其他系统上使用它。

javascript angular-cli angular

0
推荐指数
1
解决办法
1473
查看次数