我从节点服务器发送请求到其他服务器,但我需要发送内容类型
应用程序/ 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) 我正在使用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) 我需要检查 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 的所有可用方法?
我想在我的所有对象值中改变一些东西,比如说
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) 我有一个节点应用程序,在域和子域上运行.
示例:
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.com或b.abc.com它会出错
拒绝在框架中显示" http://a.abc.com ",因为它将"X-Frame-Options"设置为"sameorigin".
如何允许这个.我正在使用node/express.
Angular CLI项目在
localhost:4200
Run Code Online (Sandbox Code Playgroud)
但它不能在(我的本地主机)上运行
10.0.0.30:4200
Run Code Online (Sandbox Code Playgroud)
如何使用IP地址运行它,以便我也可以在其他系统上使用它。
javascript ×3
angular ×2
express ×2
node.js ×2
angular-cli ×1
cross-domain ×1
iframe ×1
object ×1
request ×1