Open thedarkknight197 opened 1 year ago
You need to call s.fetch()
Thank you so much I resolved using fetch in this way!
Do you like the then in this way?
public async createLinkPost(userId: number, title: string, text: string, subreddit: string, image: string) {
const r = await this.getClient(userId);
const data = r.getSubreddit(subreddit);
const post: RedditPost = {
id: uuidv4(),
title: title,
subreddit: data.display_name,
description: text,
url: '',
name: '',
image,
createdAt: Date.now(),
};
r.submitLink({
title: title,
url: text,
subredditName: data.display_name,
nsfw: true,
}).then((s: snoowrap.Submission) => {
return r.getSubmission(s.name).fetch();
}).then(submission => {
console.dir(submission)
post.name = submission.name;
post.url = submission.permalink;
this.redisService.addRedditPost(`${userId}`, post);
}).catch((error) => console.log(error));
}
Hello everybody, I am using snowcap to publish content on Reddit.
I am using typescript and when I publish any type of content, I receive a submission object with only name. I need to access to all property of object but I can't in any way.
That's my code:
What is the problem?
Thank you tu everybody