簡體   English   中英

重新發送到路徑時快遞應用程序不會替換數據

[英]express app when res.send to path it does not replace the data

我在循環中使用res.send不斷將數據放到從另一個站點拉出的網站上,但是原始站點上的數據可以更改,因此我希望它也可以在我的站點上更新,但是我無法覆蓋已發送請求。 (僅供參考,我正在使用Jira-Search從中提取數據的網站是Jira)

function getIssues(givenDir, givenQuery) {
var dir = givenDir
var query = givenQuery;
var search = require('jira-search');

console.log("Getting Issues: " + query); 
search({
  serverRoot: 'url', // the base URL for the JIRA server
  user: 'username', // the user name
  pass: 'password', // the password
  //jql: 'query"', // the JQL
  jql: query,
  //maxResults: 10, // the maximum number of results for each request to JIRA, multiple requests will be made till all the matching issues have been collected
  onTotal: function (total) {
    // optionally initialise a progress bar or something
    //console.log("Searching");
  },
  mapCallback: function (issue) {
    // This will be called for each issue matching the search.
    // Update a progress bar or something if you want here.
    // The return value from this function will be added
    // to the array returned by the promise.
    // If omitted the default behaviour is to add the whole issue
    console.log(issue.key + "   " + issue.fields.status.name);
    return issue;
  }
  }).then(function (issues) {
    // consume the collected issues array here
    //res.send(issues);
    console.log("Logging issues to: " + dir);
    app.get(dir, function(req, res){res.send(issues)});
    index++;
    main();
    return issues;
  }).done();

}

有兩種方法可以使您的站點上的數據保持最新。 一種是內置自動刷新功能,以便您在一定間隔內“拉”數據,如果您不介意間隔之間的數據過時的話。

另一種更實時的解決方案是使用套接字“推送”數據。 看一下sockets.io 您將實現類似於聊天程序的示例代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM