when I use the JS SDK to call listProducts on the cloud API, I only get back products that I am the owner of, not products that I am a member of. How can I get all the products that I am a member of (as I see when I access the console manually)?
This looks like a limitation in the current version of the particle-api-js library. The listProduct API call uses the /v1/products endpoint.
However, with the changes to allow organizations, you need to use the /v1/user/products to get all of the products that a user has access to, either because the products are owned by the user, or because the user is a team member.
For now, you can just manually call the /v1/user/products endpoint with your user token. This example is a completely unrelated API call, but is shows how to mix in API calls that are not in particle-api-js using axios fairly easily in a node app that otherwise normally uses particle-api-js. You don’t have to do it that way; you can use your preferred method of calling a REST API instead.
Great, thanks Rick.
Final code for anyone interested is:
const url = 'https://api.particle.io/v1/user/products/?access_token=' + token
const result = await axios.get(url)
if (result.status == 200) {
console.log(result.data)
}
else {
console.log(result)
}
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.