JavaScript Purging Cloudflare cache with an API call in Node.js purge cloudflare cache,cloudflare purge cache api,cloudflare purge cache

I'm looking to purge Cloudflare's cache through its API. More specially, the purge all files command.

However, I keep running into the "Invalid Content-Type header, valid values are application/json,multipart/form-data" error message, despite explicitly setting the Content-Type header with Node.js' request package.

What am I missing?


var request = require('request');

gulp.task('cfPurge', function() {

    var options = {
        url: 'https://api.cloudflare.com/client/v4/zones/myZoneID/purge_cache',
        headers: {
            'X-Auth-Email': 'email',
            'X-Auth-Key': 'myAPIkey',
            'Content-Type': 'application/json'
        },
        form: {
            'purge_everything': true,
        }
    };

    function callback(error, response, body) {
        var resp = JSON.parse(body);

        if (!error & response.statusCode == 200) {
            console.log('CF Purge: ', resp.success);
        }
        else {
            console.log('Error: ', resp.errors);
            for (var i = 0; i < resp.errors.length; i++)
                console.log('      ', resp.errors[i]);

            console.log('Message: ', resp.messages);
            console.log('Result: ', resp.result);
        }
    }

    return request.post(options, callback);
});

Output:

Error:  [ { code: 6003,
    message: 'Invalid request headers',
    error_chain: [ [Object] ] } ]
       { code: 6003,
  message: 'Invalid request headers',
  error_chain:
   [ { code: 6105,
       message: 'Invalid Content-Type header, valid values are application/json,multipart/form-data' } ] }
Message:  []
Result:  null
Answer:1

We are building a form-based app that has a complex object with many levels of nested properties. So far, I have created a simple experiment with a single view model with one object. The experiment ...

We are building a form-based app that has a complex object with many levels of nested properties. So far, I have created a simple experiment with a single view model with one object. The experiment ...

  1. bind view model in mvc
  2. bind view model to view
  3. bind viewmodel extjs
  4. wpf bind to viewmodel
  5. bind view viewmodel xaml
  6. bind view to model backbone
  7. aurelia bind view-model
  8. bind partial view model
  9. bind property view model
  10. wpf bind viewmodel property
  11. bind view to viewmodel
  12. bind view to viewmodel android
  13. bind view to viewmodel wpf
  14. prism bind view viewmodel
  15. bind button to viewmodel
  16. android bind view to model
  17. bind button click to view model
  18. angular bind view to model
  19. razor bind view to model
  20. mvvm bind view to model

I have a menu have many items. I want to show only 5 items, other items will be hidden. When clicking next or previous button, it will show other items. Should be shown like this: Here is my demo ...

I have a menu have many items. I want to show only 5 items, other items will be hidden. When clicking next or previous button, it will show other items. Should be shown like this: Here is my demo ...

I'm trying to figure out a way to search for a Greek letter in a string replace it with another character. For example value = "Hello μ!"; value.replace("μ", "You"); alert(value); //Alerted value ...

I'm trying to figure out a way to search for a Greek letter in a string replace it with another character. For example value = "Hello μ!"; value.replace("μ", "You"); alert(value); //Alerted value ...

Is there any way I can set value of array in specific index with React imutability helper ? For example something like this: const newState = update(this.state , { open[8]:{$set: false} ...

Is there any way I can set value of array in specific index with React imutability helper ? For example something like this: const newState = update(this.state , { open[8]:{$set: false} ...

  1. react immutability helper update
  2. react immutability helper
  3. react immutability helper example
  4. react immutability helper array
  5. react immutability-helper typescript
  6. react immutability helper setstate
  7. react immutability-helper npm
  8. reactjs immutability-helper
  9. react native immutability-helper
  10. immutability-helper react state
  11. react immutability-helper