I have module like this
export default {
getRating(productId) {
return axios
.get(
`<some-paramethers>`,
)
.then(response => response.data)
.catch((error) => {
console.log('Failed to get reviews :', error);
});
},
getMultipleProductRatings(productIds) {
return axios
.get(
`<some-paramethers>`,
)
.then(response => response.data)
.catch((error) => {
console.log('Failed to get reviews :', error);
});
},
};
and I have to import one or both of this methods into my React component.
I tried like this:
import getRating from '../../my-module/path';
const ProductCards = ({ slidesCollection }) => {
const [ratingStats, setRatingStats] = useState({ averageRating: 0 });
const productId = 'xxxxxxx';
useEffect(() => {
getRating(productId).then(res => {
console.log(res);
});
}, []);
but I get error in the browser: TypeError: Object(...) is not a function
pointing at getRating function in useEffect hook