On Blog Post Created

A custom data collection named ‘PostExtraData’ has been created to store additional fields related to a blog/post. A reference field has been added to the Blog/Posts collection to establish a link between the two data collections. The objective is to automatically add a post to ‘PostExtraData’ upon its creation.
An attempt has been made to achieve this through a code implementation, which is not working. The issue seems to be related to the ‘internal id’ of the post, which is not explicitly documented in the Velo document. Therefore, advice is being sought to resolve this problem.

export function wixBlog_onPostCreated(event) {
    return wixData.insert("PostExtraData", { _id: event.metadata.entityId, post: event.metadata.entityId})
        .catch(err => {
            if (err.errorCode === "WDE0074") {
                return Promise.resolve("Post_already_exists");
            }
        })
}

I don’t see that you are using CONSOLE-LOGs inside of your CODE.
If you want to RESOLVE a coding issue —> start to use more CONSOLE-LOGs.

Another example will show you what i mean…
Read…

INPUT & OUTPUT!!!

Investigate everything what happens.
-which results you get back?
-is the value you need inside the results?

Regarding the provided API-CODE, you seem to be on the right track…

// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.

export function wixBlog_onPostCreated(event) {
  const postId = event.metadata.entityId;
  const memberId = event.entity.memberId;
  console.log('Post created', event);
}

I never used Wix-Blog-APP, so i can’t tell you much about it, but if you follow my suggestion → USING MORE THE CONSOLE AND IT’S RESULTS <— you will get your problem resolved.

BETTER VERSION: Without have a view onto your project…

// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.

export function wixBlog_onPostCreated(event) {
  console.log(event); //--> inspect the resulted OBJECT here.
  //--> Brainstorming and searching for right data inside object.
  //You found for example --> metadata inside Object?
  //How do i know this? --> Just looking onto the given code and open it like a book.... xDDDDDD
  
  //so...i found --->metadata <-- take a look inside...
  
  console.log(event.metadata);
  
  //now you see --> entityId <--
  
  console.log(event.metadata.entityId);
  //...memberId...
  console.log(event.metadata.entityId);
  
  //...and so on...
  // what else you can find inside the object, what you can use later ???
  //What else is inside ---> "event" ???
  //Are there more options then just ---> "event" ?
  
  //Working that way --> you always will get your RESULT!
  console.log('Post created', event);
}