mirror of
https://github.com/strapi/strapi.git
synced 2025-10-12 08:36:40 +00:00
Merge branch 'master' of https://github.com/Sayegh7/strapi
This commit is contained in:
commit
df7be9bf73
@ -63,10 +63,10 @@ Do the same thing for other environments.
|
|||||||
|
|
||||||
#### HTTP call
|
#### HTTP call
|
||||||
|
|
||||||
Now it is time to make the HTTP call. In this example we will use `request` as it is already in the list of Strapi's dependencies. Let's install it:
|
Now it is time to make the HTTP call. In this example we will use `axios`. Let's install it:
|
||||||
|
|
||||||
```
|
```
|
||||||
npm i request --save
|
npm i axios --save
|
||||||
```
|
```
|
||||||
|
|
||||||
Edit `api/yourContentType/models/YourContentType.js`:
|
Edit `api/yourContentType/models/YourContentType.js`:
|
||||||
@ -76,7 +76,7 @@ Edit `api/yourContentType/models/YourContentType.js`:
|
|||||||
```js
|
```js
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const request = require('request');
|
const axios = require('axios');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lifecycle callbacks for the `Post` model.
|
* Lifecycle callbacks for the `Post` model.
|
||||||
@ -119,5 +119,5 @@ So, to trigger an url on delete, please add `request.post(strapi.config.currentE
|
|||||||
- `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
|
||||||
Do not forget to require `request` at the top of these files.
|
Do not forget to require `axios` at the top of these files.
|
||||||
:::
|
:::
|
||||||
|
@ -58,6 +58,7 @@ module.exports = function() {
|
|||||||
$('body').attr('back', `/`);
|
$('body').attr('back', `/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strapi.config.currentEnvironment.server.production) {
|
||||||
fs.writeFile(sourcePath, $.html(), (err) => {
|
fs.writeFile(sourcePath, $.html(), (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return reject(err);
|
return reject(err);
|
||||||
@ -65,6 +66,7 @@ module.exports = function() {
|
|||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user