What calls app.post(/webhook)? What’s the non-error response from the function call? Is it creating four posts with the same content but different slugs?
when I create an article I trigger the “Post published” event, it calls the url http://localhost:9000/webhook
then in app.post('/webhook') I take all the information of the post, modify some things of my interest and insert a new article with axios.post(urlInsert), but the result of this is the insertion of an infinite number of articles with different slugs
Publish
Published webhook
Edit data
Publish new post
The original article is not changed
So at the end of the cycle I have two articles published.
The first article published from the Ghost backend, and the second posted with the API using the modified data of the first.
At least that’s what I try to do, it actually creates an infinite loop.
Yeah. Because when you publish the second post via the API, it triggers another webhook, which kicks off the whole process again and again.
What I think you could do would be to tag your original post, then check for that tag in your JS. If it’s there, remove it for the new post with edited data. That way, you can stop execution for any post that doesn’t have that tag and stop the loop.