mirror of
https://github.com/strapi/strapi.git
synced 2025-11-23 13:40:58 +00:00
Replace restaurant in webhook doc
This commit is contained in:
parent
22615a1db9
commit
2580b471d4
@ -15,11 +15,11 @@ As you may know, every Content Type (aka models) has lifecycle callbacks: functi
|
|||||||
- Callbacks on `update`: `beforeUpdate`, `afterUpdate`.
|
- Callbacks on `update`: `beforeUpdate`, `afterUpdate`.
|
||||||
- Callbacks on `destroy`: `beforeDestroy`, `afterDestroy`.
|
- Callbacks on `destroy`: `beforeDestroy`, `afterDestroy`.
|
||||||
|
|
||||||
All of these functions are available in a file located at `api/yourContentType/models/YourContentType.js`.
|
All of these functions are available in a file located at `api/restaurant/models/Restaurant.js`.
|
||||||
|
|
||||||
If your goal is to rebuild a static website, the only useful callbacks are `afterCreate`, `afterUpdate` and `afterDestroy`. So, uncomment them, add logs and try to create, update and delete entries from the admin panel.
|
If your goal is to rebuild a static website, the only useful callbacks are `afterCreate`, `afterUpdate` and `afterDestroy`. So, uncomment them, add logs and try to create, update and delete entries from the admin panel.
|
||||||
|
|
||||||
**Path —** `api/yourContentType/models/YourContentType.js`.
|
**Path —** `api/restaurant/models/Restaurant.js`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -29,17 +29,17 @@ If your goal is to rebuild a static website, the only useful callbacks are `afte
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
afterCreate: async (entry) => {
|
afterCreate: async entry => {
|
||||||
console.log('afterCreate');
|
console.log('afterCreate');
|
||||||
},
|
},
|
||||||
|
|
||||||
afterUpdate: async (entry) => {
|
afterUpdate: async entry => {
|
||||||
console.log('afterUpdate');
|
console.log('afterUpdate');
|
||||||
},
|
},
|
||||||
|
|
||||||
afterDestroy: async (entry) => {
|
afterDestroy: async entry => {
|
||||||
console.log('afterDestroy');
|
console.log('afterDestroy');
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -69,9 +69,9 @@ Now it is time to make the HTTP call. In this example we will use `axios`. Let's
|
|||||||
npm i axios --save
|
npm i axios --save
|
||||||
```
|
```
|
||||||
|
|
||||||
Edit `api/yourContentType/models/YourContentType.js`:
|
Edit `api/restaurant/models/Restaurant.js`:
|
||||||
|
|
||||||
**Path —** `api/yourContentType/models/YourContentType.js`.
|
**Path —** `api/restaurant/models/Restaurant.js`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -83,29 +83,29 @@ const axios = require('axios');
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
afterCreate: async (entry) => {
|
afterCreate: async entry => {
|
||||||
axios.post(strapi.config.currentEnvironment.staticWebsiteBuildURL, entry)
|
axios
|
||||||
|
.post(strapi.config.currentEnvironment.staticWebsiteBuildURL, entry)
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
afterUpdate: async (entry) => {
|
afterUpdate: async entry => {
|
||||||
axios.post(strapi.config.currentEnvironment.staticWebsiteBuildURL, entry)
|
axios
|
||||||
|
.post(strapi.config.currentEnvironment.staticWebsiteBuildURL, entry)
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
afterDestroy: async (entry) => {
|
afterDestroy: async entry => {
|
||||||
axios.post(strapi.config.currentEnvironment.staticWebsiteBuildURL, entry)
|
axios
|
||||||
|
.post(strapi.config.currentEnvironment.staticWebsiteBuildURL, entry)
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// Ignore
|
// Ignore
|
||||||
}
|
});
|
||||||
);
|
},
|
||||||
}
|
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ Until September 2018, `remove` lifecycle callback [was not supported by Mongoose
|
|||||||
|
|
||||||
So, to trigger an url on delete, please add `request.post(strapi.config.currentEnvironment.staticWebsiteBuildURL, entry);` in:
|
So, to trigger an url on delete, please add `request.post(strapi.config.currentEnvironment.staticWebsiteBuildURL, entry);` in:
|
||||||
|
|
||||||
- `remove` action of `api/yourContentType/services/YourContentType.js` (triggered by your public API).
|
- `remove` action of `api/restaurant/services/Restaurant.js` (triggered by your public API).
|
||||||
- `delete` action of `plugins/content-manager/services/ContentManager.js` (triggered by the Content Manager).
|
- `delete` action of `plugins/content-manager/services/ContentManager.js` (triggered by the Content Manager).
|
||||||
|
|
||||||
::: note
|
::: note
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user