簡體   English   中英

如何獲取回購的最后一次提交日期?

[英]How to get the date of last commit of repo?

示例 JSON:

[
  {
    "sha": "0bf21a1dc1c03f11bb44ac32a65c17b5857b020c",
    "node_id": "MDyODE2MY6Q29tbWl0NzYGJmMjFjYzE3YjUwM2YxMDk6MWJiNDRhYzMyYTFkYzFhNjU4NTdiMDIwYw==",
    "commit": {
      "author": {
        "name": "Max Mustermann",
        "email": "max@mustermann.at",
        "date": "2016-12-12T19:56:46Z"
      },
      "committer": {
        "name": "GitHub",
        "email": "noreply@github.com",
        "date": "2016-12-12T19:56:46Z"
      },
      "message": "Update README.md", ...

如何獲取 javascript 中的提交日期 -> 作者 -> 日期
我的測試:

fetch("https://api.github.com/repos/schletz/3KanalAdWandler/commits", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result.commit.author.date))
  .catch(error => console.log('error', error));

我得到的是: TypeError: Cannot read properties of undefined (reading 'author')

result似乎是一個數組,因此您必須包含數組索引。 console.log(result[0].commit.author.date)

暫無
暫無

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

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