Skip to content

获取部署

js
const https = require('https')

const options = {
  hostname: 'api.cloudflare.com',
  method: 'GET',
  headers: {
    Authorization: 'Bearer ohtStf0CCwqgOZ3Tw7zlx2bZaRCxb-7TQkvU3WCJ'
  }
}

const getDeployments = project => {
  const path = `/client/v4/accounts/3b5032bb4aa6f6f3cc65dd08f85d3645/pages/projects/${projecrt}/deployments`
  path.path = path
  const req = https.request(options, res => {
    let data = ''

    res.on('data', chunk => {
      data += chunk
    })

    res.on('end', () => {
      try {
        const res = JSON.parse(data)
        console.log(res.result[0].id)
      } catch (e) {
        console.error(e)
      }
    })
  })

  req.end()
}