Pulling data from Bubble with axios and bubble API token

Hi,

I managed to retrieve my Products data in Postman with my Products API url and the token I created.
However when I try to get my Products data in my app backend it returns the data but with an empty array as if the token hasn’t been used to access it.

I have use the same values and copy/paste them from the console to Postman to make sure they are the same:

 const config = {
            headers: {
                'Authorization': `Bearer ${BBL_APP_TOKEN}`
            }
 }                 

const bubbleListing = await axios.get(`${BBL_URL}products`, { config } )
     .catch(error => {
            console.error(error)
     })

With axios I get this empty array in “result” :

"data": {
    "cursor": 0,
    "results": [],
    "remaining": 0,
    "count": 0
}

Edit:

I’m not sure why :slight_smile: but I found out that it works when I write :
await axios.get(${BBL_URL}listing, { headers: {'Authorization' : Bearer ${BBL_APP_TOKEN}} } )

instead of :
await axios.get(${BBL_URL}products, { config } )

This topic was automatically closed after 70 days. New replies are no longer allowed.