以编程方式清除cloudflare缓存

在将请求发送到node.js api之后,我试图以编程方式清除单个网址的cloudflare缓存.我正在使用 https://github.com/cloudflare/node-cloudflare 库,但是我无法弄清楚如何从cloudflare记录回调.根据同一仓库中的测试文件,语法应如下所示:

I am trying to clear the cloudflare cache for single urls programmatically after put requests to a node.js api. I am using the https://github.com/cloudflare/node-cloudflare library, however I can't figure out how to log a callback from cloudflare. According to the test file in the same repo, the syntax should be something like this:

//client declaration:

    t.context.cf = new CF({
        key: 'deadbeef',
        email: 'cloudflare@example.com',
        h2: false
      });

//invoke clearCache:

           t.context.cf.deleteCache('1', {
            files: [
              'https://example.com/purge_url'
            ]
          })

如何从该请求中读出回调? 我已经在自己的代码中尝试了以下方法:

How can I read out the callback from this request? I have tried the following in my own code:

client.deleteCache(process.env.CLOUDFLARE_ZONE, { "files": [url] }, function (data) {
    console.log(`Cloudflare cache purged for: ${url}`);
    console.log(`Callback:${data}`);
})

和:

client.deleteCache('1', {
    files: [
        'https://example.com/purge_url'
    ]
}).then(function(a,b){
    console.log('helllllllooooooooo');
})

无济于事. :(



 1 条回答