如何对安全 URL 执行 HTTP 发布请求



我收到此链接,其中包含 API 参考 http://api.fang88.com/api/we_article/get_all_audited_we_article_列表
但是当我点击它时,浏览器说它坏了给我这个的人说它不能通过浏览器打开,我需要用空参数{}对这个网址做一个HTTP发布请求。

我有

var express = require('express');
var app = express();
app.use(express.static(__dirname));
app.get('/', function(req, res){
  res.redirect('/index.html');
});
app.listen(8080);

和这个 JSON 文件

{
  "name": "fang88",
  "version": "1.0.0",
  "authors": [
    "Fang88.com, Inc."
  ],
  "description": "Fang88",
  "keywords": [
    "Fang88",
    "Interview"
  ],
  "private": true,
  "ignore": [
    "**/.*",
    "node_modules",
    "bower_components"
  ],
  "dependencies": {
    "angular": "~1.6.3"
  }
}

说如果我打开它,我会得到另一个 json 文件。如何使用 javascript 来做到这一点?

app.post 告诉Express JS监听请求/并在看到函数时运行该函数。当它被发布时,会有成功或失败或失败。数据库操作基于成功或失败而发生。因此,我们将错误响应称为失败时抛出错误,并使用"记录更新!"字符串发送响应。.db。Operation.collection.insert <<<---是MongoDB的一种收集方法。例:

app.post('/todo', function(req, res) {
  dbOperation.collection('todo').insert(req.body,function(err, result){
    if (err) throw err
    res.send("Record added !");
  })
})

在控制器.js中:

    todo.createTask=function(){      //it is expression for ng-click parameter
  var data = [{                  //as button clicks, the variable data array is declared and with the values of object property.
    name: todo.model.txtTask,
    status:"Pending"
  }];
  $http.post("/todo",data).then(function(response){  //this is $http service shortcut method, used to send the data to specific URL, means it inserts new data based on given URL.
      alert(response.data);
    function(error){
      console.log(error, "Error!");
    })
  }

最新更新