I have a function defined in a file which calls an async function and also a normal function. I have defined them in this way
const cms_service = {
fetchSinglePost: function(post){
const image = await cms_service.fetchImageData(post)
let single_post = {
post: cms_service.fetchPostData(post),
image: image
}
return single_post
},
fetchPostData: function (post) {
var post_response = {
id: post.data[0].id
}
return post_response
},
fetchImageData: async function (post) {
let storyplay_response = {}
if(typeof post.data[0].tmc_storyplay[0] !== 'undefined' && post.data[0].tmc_storyplay[0]){
const storyplay = await axios.get(cms_service_url+"tmc_storyplay/"+post.data[0].tmc_storyplay[0], requestHeader);
storyplay_response = {
id: storyplay.data.id
}
}
return storyplay_response
}
}
module.exports = cms_service;
But it throws me an error saying
TypeError: this.fetchPostData is not a function
How do I correct this?