Hello,
Very bizarre that the catalog API requires a x-csrf-token header, but it doesn’t need to? From all I checked, it was just a simple POST request, and then you would get the data from there. I don’t know how to fix the error… all the other posts seem to be about logging in with a .ROBLOSECURITY cookie… Anyways, here’s the script:
try {
const args = message.content.split(' ')
const assetId = args[1]
const res = await fetch('https://catalog.roproxy.com/v1/catalog/items/details', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: {
'items': [
{
'itemType': 1,
'id': assetId
}
]
}
})
const result = await res.json()
console.log(result)
const res_Data = result['data'][0]
var restrict_String = ''
for (let data of res_Data['itemRestrictions']) {
restrict_String += (data + ' ') || 'None'
}
var status_String = ''
for (let data of res_Data['status']) {
status_String += (data + ' ') || 'None'
}
var genre_String = ''
for (let data of res_Data['genres']) {
genre_String += (data + ' ') || 'None'
}
const embed = new EmbedBuilder()
.setColor("Random")
.setTitle(res_Data['name'])
.setDescription(res_Data['name'] + ' Info:')
.addFields(
{name: 'Info:', value: '**Description:** "' + res_Data['description'] + '\n **ID (asset, product):** ' + res_Data['id'] + ',' + res_Data['productId'] + '\n **Genres:** ' + genre_String + '\n **Status:** ' + status_String + '\n **Restrictions:** ' + restrict_String + '\n **Verified Creator:** ' + res_Data['creatorHasVerifiedBadge'] + '\n **Creator Name:** ' + res_Data['creatorName'] + '\n **Creator ID:** ' + res_Data['creatorTargetId'] + '\n **Price (normal, lowest):** ' + res_Data['price'] + ', ' + res_Data['lowestPrice'] + '\n **Favorite Count ⭐:** ' + res_Data['favoriteCount'] + '\n **Offsale Deadline:** ' + (res_Data['offSaleDeadline'] || 'Never') + '\n **Quantity (Total):**' + res_Data['totalQuantity']}
)
await message.reply({embeds: [embed]})
} catch(err) {await message.reply("Asset fetch failed!"); console.warn(err)}
}
Help is appreciated