fastly/fastly-js

Incorrect return value of `bulkPurgeTag`

dios-david opened this issue · 3 comments

Version

Using 3.0.0-beta3

What happened

I tried to purge multiple surrogate keys in one go, and I found a method called bulkPurgeTag which supposed to do exactly that.
The documentation is little bit unclear for me, as it suggests to pass in the surrogate keys in a field called purge_response 🤔 I did this:

const Fastly = require('fastly');

const FASTLY_SERVICE_ID = '...';
const FASTLY_API_TOKEN = '...';

Fastly.ApiClient.instance.authenticate(FASTLY_API_TOKEN);

const apiInstance = new Fastly.PurgeApi();

const response = await apiInstance.bulkPurgeTag({
  service_id: FASTLY_SERVICE_ID,
  fastly_soft_purge: 0,
  purge_response: {
    surrogate_keys: ['test_key_1', 'test_key_2']
  },
});

console.log(response);

Which look to be working fine, but the response looks like this:

{
  '0': '{',
  '1': ' ',
  '2': '"',
  '3': 'p',
  '4': 'a',
  '5': 't',
  '6': 'h',
  '7': ':',
  '8': 't',
  '9': 'e',
  '10': 's',
  '11': 't',
  '12': '_',
  '13': 'k',
  '14': 'e',
  '15': 'y',
  '16': '_',
  '17': '1',
  '18': '"',
  '19': ':',
  '20': ' ',
  '21': '"',
  '22': '4',
  '23': '2',
  '24': '6',
  '25': '9',
  '26': '-',
  '27': '1',
  '28': '6',
  '29': '5',
  '30': '0',
  '31': '4',
  '32': '6',
  '33': '5',
  '34': '6',
  '35': '8',
  '36': '2',
  '37': '-',
  '38': '3',
  '39': '8',
  '40': '5',
  '41': '7',
  '42': '1',
  '43': '"',
  '44': ',',
  '45': ' ',
  '46': '"',
  '47': 'p',
  '48': 'a',
  '49': 't',
  '50': 'h',
  '51': ':',
  '52': 't',
  '53': 'e',
  '54': 's',
  '55': 't',
  '56': '_',
  '57': 'k',
  '58': 'e',
  '59': 'y',
  '60': '_',
  '61': '2',
  '62': '"',
  '63': ':',
  '64': ' ',
  '65': '"',
  '66': '4',
  '67': '2',
  '68': '6',
  '69': '9',
  '70': '-',
  '71': '1',
  '72': '6',
  '73': '5',
  '74': '0',
  '75': '4',
  '76': '6',
  '77': '5',
  '78': '6',
  '79': '8',
  '80': '2',
  '81': '-',
  '82': '3',
  '83': '8',
  '84': '5',
  '85': '7',
  '86': '2',
  '87': '"',
  '88': ' ',
  '89': '}'
}

Which looks like the character array of the stringified purge response.

Can confirm this is still an issue with 3.1.0