Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting data from Webhook #30

Closed
orjanskaar opened this issue May 14, 2022 · 4 comments
Closed

Getting data from Webhook #30

orjanskaar opened this issue May 14, 2022 · 4 comments

Comments

@orjanskaar
Copy link

Hi

I've managed to get my webhook firing for the "StockMovementEvent" using the POST method

WebhookPlugin.init({
    httpMethod: 'POST',
    delay: 3000, // Optional if you want to wait for more events
    events: [ProductOptionEvent, ProductVariantChannelEvent, ProductVariantEvent, StockMovementEvent],
})

I only get an empty string on "request.body". (Like the readme hints to)

Is there some way to configure what data to send like the current stock balance?

@martijnvdbrug
Copy link
Member

@orjanskaar Right now, the plugin only sends an empty POST request. Feel free to open a PR, it shouldn't be too complicated to implement in the existing code.

@martijnvdbrug
Copy link
Member

@orjanskaar
Copy link
Author

Hello

I would love to try and help out and give it a go, but im am pretty shure this is just beyond my programming capabilities right now.
So any help would be apreciated.

@martijnvdbrug
Copy link
Member

@orjanskaar vendure-plugin-webhook v3.12.0 now allows you to define a POST body (and headers) via a custom function:

WebhookPlugin.init({
    httpMethod: 'POST',
    events: [ProductEvent, ProductVariantChannelEvent, ProductVariantEvent],
    requestFn: (event) => {
      return {
        headers: { test: '1234' },
        body: JSON.stringify({ createdAt: event.createdAt }),
      };
    },
  }),

Let me know if you have any questions.

Closed in #52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants