diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/11ty.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/11ty.md index 0956ba0b87..ed0a771722 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/11ty.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/11ty.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [11ty](https://www.11ty.dev/) remains the same except that you will not fetch the same content. @@ -139,7 +139,7 @@ const { default: axios } = require('axios'); module.exports = async () => { try { - const res = await axios.get('http://localhost:1337/restaurants'); + const res = await axios.get('http://localhost:1337/api/restaurants'); return res.data; } catch (error) { console.error(error); @@ -195,7 +195,7 @@ const { default: axios } = require('axios'); module.exports = async () => { try { - const res = await axios.get('http://localhost:1337/restaurants'); + const res = await axios.get('http://localhost:1337/api/restaurants'); return res.data; } catch (error) { console.error(error); @@ -261,7 +261,7 @@ const { default: axios } = require('axios'); module.exports = async () => { try { - const res = await axios.get('http://localhost:1337/categories'); + const res = await axios.get('http://localhost:1337/api/categories'); return res.data; } catch (error) { console.error(error); @@ -328,7 +328,7 @@ const { default: axios } = require('axios'); module.exports = async () => { try { - const res = await axios.get('http://localhost:1337/categories'); + const res = await axios.get('http://localhost:1337/api/categories'); return res.data; } catch (error) { console.error(error); diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/angular.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/angular.md index 4e498cb90e..36652955f2 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/angular.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/angular.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [Angular](https://angular.io) remains the same except that you will not fetch the same content. @@ -56,7 +56,7 @@ Be sure that you activated the `find` permission for the `restaurant` Collection ```js import axios from 'axios'; -axios.get('http://localhost:1337/restaurants').then(response => { +axios.get('http://localhost:1337/api/restaurants').then(response => { console.log(response); }); ``` @@ -68,7 +68,7 @@ axios.get('http://localhost:1337/restaurants').then(response => { ::: request Example GET request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -142,7 +142,7 @@ export class AppComponent implements OnInit { async ngOnInit() { try { - const response = await axios.get('http://localhost:1337/restaurants'); + const response = await axios.get('http://localhost:1337/api/restaurants'); this.restaurants = response.data; } catch (error) { this.error = error; @@ -187,7 +187,7 @@ export class AppComponent implements OnInit { async ngOnInit() { try { - const restaurants = await fetch('http://localhost:1337/restaurants', { + const restaurants = await fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: headers, }) @@ -234,7 +234,7 @@ In this example a `japanese` category has been created which has the id: 3. import axios from 'axios'; axios - .post('http://localhost:1337/restaurants', { + .post('http://localhost:1337/api/restaurants', { name: 'Dolemon Sushi', description: 'Unmissable Japanese Sushi restaurant. The cheese and salmon makis are delicious', categories: [3], @@ -251,7 +251,7 @@ axios ::: request Example POST request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -370,7 +370,7 @@ export class AppComponent implements OnInit { async ngOnInit() { try { - const response = await axios.get('http://localhost:1337/categories'); + const response = await axios.get('http://localhost:1337/api/categories'); this.allCategories = response.data } catch (error) { this.error = error @@ -381,7 +381,7 @@ export class AppComponent implements OnInit { async onSubmit(restaurantData) { try { const response = await axios.post( - 'http://localhost:1337/restaurants', + 'http://localhost:1337/api/restaurants', restaurantData ); console.log(response); @@ -463,7 +463,7 @@ export class AppComponent implements OnInit { async ngOnInit() { try { - const allCategories = await fetch('http://localhost:1337/categories', { + const allCategories = await fetch('http://localhost:1337/api/categories', { method: 'GET', headers: headers, }) @@ -478,7 +478,7 @@ export class AppComponent implements OnInit { async onSubmit(restaurantData) { try { - await fetch('http://localhost:1337/restaurants', { + await fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: headers, body: JSON.stringify(restaurantData), @@ -550,7 +550,7 @@ and the id of your category is `2`. import axios from 'axios'; axios - .put('http://localhost:1337/restaurants/2', { + .put('http://localhost:1337/api/restaurants/2', { categories: [2], }) .then(response => { @@ -565,7 +565,7 @@ axios ::: request Example PUT request with fetch ```js -fetch('http://localhost:1337/restaurants/2', { +fetch('http://localhost:1337/api/restaurants/2', { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/go.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/go.md index 71161d25fd..ba585cfc70 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/go.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/go.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start guide, the way you request a Strapi API with [GO](https://golang.org/) remains the same except that you will not fetch the same content. @@ -35,7 +35,7 @@ Be sure that you activated the `find` permission for the `restaurant` Collection ::: request Example GET request ```go -response, error := http.Get("http://localhost:1337/restaurants") +response, error := http.Get("http://localhost:1337/api/restaurants") ``` ::: @@ -87,7 +87,7 @@ func main() { func getD() { fmt.Println("Getting data...") - res, error := http.Get("http://localhost:1337/restaurants") + res, error := http.Get("http://localhost:1337/api/restaurants") if error != nil { fmt.Printf("The HTTP request failed with error %s\n", error) } else { @@ -111,7 +111,7 @@ postRest, _ := json.Marshal(map[string]string{ "description": "This is a very nice place to eat native soup", }) responseBody := bytes.NewBuffer(postRest) -resp, error := http.Post("http://localhost:1337/restaurants", "application/json", responseBody) +resp, error := http.Post("http://localhost:1337/api/restaurants", "application/json", responseBody) ``` ::: @@ -150,7 +150,7 @@ func main() { func getD() { fmt.Println("Getting data...") - resp, error := http.Get("http://localhost:1337/restaurants") + resp, error := http.Get("http://localhost:1337/api/restaurants") if error != nil { fmt.Printf("The HTTP request failed with error %s\n", error) } else { @@ -167,7 +167,7 @@ func postD() { "description": "This is a very nice place to eat native soup", }) responseBody := bytes.NewBuffer(postRest) - resp, error := http.Post("http://localhost:1337/restaurants", "application/json", responseBody) + resp, error := http.Post("http://localhost:1337/api/restaurants", "application/json", responseBody) //Handle Error if error != nil { log.Fatalf("An Error Occured %v", error) @@ -188,7 +188,7 @@ func postD() { Execute a `PUT` request on the `restaurant` Collection Type in order to update the category of a restaurant. Be sure that you activated the `update` permission for the `restaurant` Collection Type. -PUT Request is sligtly different as we need to target the particular thing we want update. We do this by first making a request to http://localhost:1337/restaurants/1 and then update what we want to update. In this example, we are going to update "Biscotte Restaurant" to "Restaurant Home". +PUT Request is sligtly different as we need to target the particular thing we want update. We do this by first making a request to http://localhost:1337/api/restaurants/1 and then update what we want to update. In this example, we are going to update "Biscotte Restaurant" to "Restaurant Home". :::: api-call ::: request Example PUT request @@ -198,7 +198,7 @@ putRest, _ := json.Marshal(map[string]string { "name": "Resturant Homes", }) client := &http.Client{} -url := "http://localhost:1337/restaurants/1" +url := "http://localhost:1337/api/restaurants/1" req, error := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(putRest)) req.Header.Set("Content-Type", "application/json") ``` @@ -256,7 +256,7 @@ func main() { } func getD() { fmt.Println("Getting data...") - resp, error := http.Get("http://localhost:1337/restaurants") + resp, error := http.Get("http://localhost:1337/api/restaurants") if error != nil { fmt.Printf("The HTTP request failed with error %s\n", error) } else { @@ -274,7 +274,7 @@ func postD() { }) responseBody := bytes.NewBuffer(postRest) - resp, error := http.Post("http://localhost:1337/restaurants", "application/json", responseBody) + resp, error := http.Post("http://localhost:1337/api/restaurants", "application/json", responseBody) // Handle Error if error != nil { log.Fatalf("An Error Occured %v", error) @@ -293,7 +293,7 @@ func putD() { "name": "Resturant Homes", }) client := &http.Client{} - url := "http://localhost:1337/restaurants/1" + url := "http://localhost:1337/api/restaurants/1" req, error := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(putRest)) req.Header.Set("Content-Type", "application/json") if error != nil { diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/next-js.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/next-js.md index 39da8dec14..59cc90861b 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/next-js.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/next-js.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [Next.js](https://nextjs.org/) remains the same except that you will not fetch the same content. @@ -67,7 +67,7 @@ Be sure that you activated the `find` permission for the `restaurant` Collection ```js import axios from 'axios'; -axios.get('http://localhost:1337/restaurants').then(response => { +axios.get('http://localhost:1337/api/restaurants').then(response => { console.log(response); }); ``` @@ -79,7 +79,7 @@ axios.get('http://localhost:1337/restaurants').then(response => { ::: request Example GET request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -156,7 +156,7 @@ const Home = ({ restaurants, error }) => { Home.getInitialProps = async ctx => { try { - const res = await axios.get('http://localhost:1337/restaurants'); + const res = await axios.get('http://localhost:1337/api/restaurants'); const restaurants = res.data; return { restaurants }; } catch (error) { @@ -205,7 +205,7 @@ Home.getInitialProps = async ctx => { 'Content-Type': 'application/json', }; - const restaurants = await fetch('http://localhost:1337/restaurants', { + const restaurants = await fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers, }) @@ -242,7 +242,7 @@ In this example a `japanese` category has been created which has the id: 3. import axios from 'axios'; axios - .post('http://localhost:1337/restaurants', { + .post('http://localhost:1337/api/restaurants', { name: 'Dolemon Sushi', description: 'Unmissable Japanese Sushi restaurant. The cheese and salmon makis are delicious', categories: [3], @@ -258,7 +258,7 @@ axios :::: tab fetch ::: request Example POST request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -333,7 +333,7 @@ const Home = ({ allCategories, errorCategories }) => { e.preventDefault(); try { - const response = await axios.post('http://localhost:1337/restaurants', modifiedData); + const response = await axios.post('http://localhost:1337/api/restaurants', modifiedData); console.log(response); } catch (error) { setErrorRestaurants(error); @@ -404,7 +404,7 @@ const Home = ({ allCategories, errorCategories }) => { Home.getInitialProps = async ctx => { try { - const res = await axios.get('http://localhost:1337/categories'); + const res = await axios.get('http://localhost:1337/api/categories'); const allCategories = res.data; return { allCategories }; } catch (errorCategories) { @@ -458,7 +458,7 @@ const Home = ({ allCategories, errorCategories }) => { e.preventDefault(); try { - const response = await fetch('http://localhost:1337/restaurants', { + const response = await fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers, body: JSON.stringify(modifiedData), @@ -536,7 +536,7 @@ const Home = ({ allCategories, errorCategories }) => { Home.getInitialProps = async ctx => { try { - const allCategories = await fetch('http://localhost:1337/categories', { + const allCategories = await fetch('http://localhost:1337/api/categories', { method: 'GET', headers, }) @@ -572,7 +572,7 @@ and the id of your category is `2`. import axios from 'axios'; axios - .put('http://localhost:1337/restaurants/2', { + .put('http://localhost:1337/api/restaurants/2', { categories: [2], }) .then(response => { @@ -586,7 +586,7 @@ axios :::: tab fetch ::: request Example PUT request with fetch ```js -fetch('http://localhost:1337/restaurants/2', { +fetch('http://localhost:1337/api/restaurants/2', { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/nuxt-js.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/nuxt-js.md index 33afacfc16..dc4b78d892 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/nuxt-js.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/nuxt-js.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [Nuxt.js](https://nuxtjs.org/) remains the same except that you will not fetch the same content. @@ -102,7 +102,7 @@ try { ```js import axios from 'axios'; -axios.get('http://localhost:1337/restaurants').then(response => { +axios.get('http://localhost:1337/api/restaurants').then(response => { console.log(response); }); ``` @@ -114,7 +114,7 @@ axios.get('http://localhost:1337/restaurants').then(response => { ::: request Example GET request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -240,7 +240,7 @@ export default { }, async mounted () { try { - const response = await axios.get('http://localhost:1337/restaurants') + const response = await axios.get('http://localhost:1337/api/restaurants') this.restaurants = response.data } catch (error) { this.error = error; @@ -296,7 +296,7 @@ export default { }, async mounted () { try { - const response = await fetch("http://localhost:1337/restaurants", { + const response = await fetch("http://localhost:1337/api/restaurants", { method: 'GET', headers: this.headers, }).then(this.checkStatus) @@ -349,7 +349,7 @@ try { import axios from 'axios'; axios - .post('http://localhost:1337/restaurants', { + .post('http://localhost:1337/api/restaurants', { name: 'Dolemon Sushi', description: 'Unmissable Japanese Sushi restaurant. The cheese and salmon makis are delicious', categories: [3], @@ -365,7 +365,7 @@ axios :::: tab fetch ::: request Example POST request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -551,7 +551,7 @@ export default { }, async mounted() { try { - const response = await axios.get('http://localhost:1337/categories') + const response = await axios.get('http://localhost:1337/api/categories') this.allCategories = response.data; } catch (error) { this.error = error; @@ -562,7 +562,7 @@ export default { e.preventDefault(); try { - const response = await axios.post('http://localhost:1337/restaurants', this.modifiedData) + const response = await axios.post('http://localhost:1337/api/restaurants', this.modifiedData) console.log(response); } catch(error) { this.error = error; @@ -635,7 +635,7 @@ export default { }, async mounted() { try { - const allCategories = await fetch("http://localhost:1337/categories", { + const allCategories = await fetch("http://localhost:1337/api/categories", { method: 'GET', headers: this.headers, }).then(this.checkStatus) @@ -661,7 +661,7 @@ export default { e.preventDefault(); try { - const response = await fetch('http://localhost:1337/restaurants', { + const response = await fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: this.headers, body: JSON.stringify(this.modifiedData) @@ -714,7 +714,7 @@ try { import axios from 'axios'; axios - .put('http://localhost:1337/restaurants/2', { + .put('http://localhost:1337/api/restaurants/2', { categories: [2], }) .then(response => { @@ -728,7 +728,7 @@ axios :::: tab fetch ::: request Example PUT request with fetch ```js -fetch('http://localhost:1337/restaurants/2', { +fetch('http://localhost:1337/api/restaurants/2', { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/php.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/php.md index 64890ee0a6..16664925a7 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/php.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/php.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [PHP](https://php.net/) remains the same except that you will not fetch the same content. @@ -31,7 +31,7 @@ Be sure that you activated the `find` permission for the `restaurant` Collection ::: request Example GET request ```php -curl_setopt($curl, CURLOPT_URL, 'http://localhost:1337/restaurants'); +curl_setopt($curl, CURLOPT_URL, 'http://localhost:1337/api/restaurants'); ``` Running the PHP file on the browser will give you this response: @@ -72,7 +72,7 @@ Running the PHP file on the browser will give you this response: { +axios.get('http://localhost:1337/api/restaurants').then(response => { console.log(response); }); ``` @@ -81,7 +81,7 @@ axios.get('http://localhost:1337/restaurants').then(response => { ::: request Example GET request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -154,7 +154,7 @@ class App extends React.Component { // Fetch your restaurants immediately after the component is mounted componentDidMount = async () => { try { - const response = await axios.get('http://localhost:1337/restaurants'); + const response = await axios.get('http://localhost:1337/api/restaurants'); this.setState({ restaurants: response.data }); } catch (error) { this.setState({ error }); @@ -219,7 +219,7 @@ class App extends React.Component { }; try { - const restaurants = await fetch('http://localhost:1337/restaurants', { + const restaurants = await fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: headers, }) @@ -275,7 +275,7 @@ In this example a `japanese` category has been created which has the id: 3. import axios from 'axios'; axios - .post('http://localhost:1337/restaurants', { + .post('http://localhost:1337/api/restaurants', { name: 'Dolemon Sushi', description: 'Unmissable Japanese Sushi restaurant. The cheese and salmon makis are delicious', categories: [3], @@ -292,7 +292,7 @@ axios ::: request Example POST request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -366,7 +366,7 @@ class App extends React.Component { // Fetch your categories immediately after the component is mounted componentDidMount = async () => { try { - const response = await axios.get('http://localhost:1337/categories'); + const response = await axios.get('http://localhost:1337/api/categories'); this.setState({ allCategories: response.data }); } catch (error) { this.setState({ error }); @@ -388,7 +388,7 @@ class App extends React.Component { try { const response = await axios.post( - 'http://localhost:1337/restaurants', + 'http://localhost:1337/api/restaurants', this.state.modifiedData ); console.log(response); @@ -519,7 +519,7 @@ class App extends React.Component { componentDidMount = async () => { try { - const allCategories = await fetch('http://localhost:1337/categories', { + const allCategories = await fetch('http://localhost:1337/api/categories', { method: 'GET', headers: headers, }) @@ -545,7 +545,7 @@ class App extends React.Component { e.preventDefault(); try { - await fetch('http://localhost:1337/restaurants', { + await fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: headers, body: JSON.stringify(this.state.modifiedData), @@ -660,7 +660,7 @@ We consider that the id of your restaurant is `2`, and the id of your category i import axios from 'axios'; axios - .put('http://localhost:1337/restaurants/2', { + .put('http://localhost:1337/api/restaurants/2', { categories: [2], }) .then(response => { @@ -675,7 +675,7 @@ axios ::: request Example PUT request with fetch ```js -fetch('http://localhost:1337/restaurants/2', { +fetch('http://localhost:1337/api/restaurants/2', { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/ruby.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/ruby.md index e0e3f65df9..bcefffbaa7 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/ruby.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/ruby.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [Ruby](https://www.ruby-lang.org/en/) remains the same except that you will not fetch the same content. @@ -49,7 +49,7 @@ Be sure that you activated the `find` permission for the `restaurant` Collection ::: request Example GET request ```ruby -HTTParty.get('http://localhost:1337/restaurants', +HTTParty.get('http://localhost:1337/api/restaurants', header: { 'Content-Type' => 'application/json' }) @@ -129,7 +129,7 @@ In this example a `japanese` category has been created which has the id: 3. ::: request Example POST request ```ruby -HTTParty.post("http://localhost:1337/restaurants", +HTTParty.post("http://localhost:1337/api/restaurants", body: { name: 'Dolemon Sushi', description: 'Unmissable Japanese Sushi restaurant. The cheese and salmon makis are delicious', @@ -218,7 +218,7 @@ Be sure that you activated the `put` permission for the `restaurant` Collection ::: request Example PUT request ```ruby -HTTParty.put("http://localhost:1337/restaurants/2", +HTTParty.put("http://localhost:1337/api/restaurants/2", body: { categories: [2] }, diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/sapper.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/sapper.md index 37dfc11601..4059bec61f 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/sapper.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/sapper.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [Sapper](https://sapper.svelte.dev) remains the same except that you will not fetch the same content. @@ -61,7 +61,7 @@ Be sure that you activated the `find` permission for the `restaurant` Collection ```js import axios from 'axios'; -axios.get('http://localhost:1337/restaurants').then(response => { +axios.get('http://localhost:1337/api/restaurants').then(response => { console.log(response); }); ``` @@ -74,7 +74,7 @@ axios.get('http://localhost:1337/restaurants').then(response => { ::: request Example GET request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -144,7 +144,7 @@ let error = null onMount(async () => { try { - const res = await axios.get('http://localhost:1337/restaurants'); + const res = await axios.get('http://localhost:1337/api/restaurants'); restaurants = res.data } catch (e) { error = e @@ -194,7 +194,7 @@ onMount(async () => { }; try { - const res = await fetch("http://localhost:1337/restaurants", { + const res = await fetch("http://localhost:1337/api/restaurants", { method: "GET", headers: { 'Content-Type': 'application/json' @@ -242,7 +242,7 @@ In this example a `japanese` category has been created which has the id: 3. import axios from 'axios'; axios - .post('http://localhost:1337/restaurants', { + .post('http://localhost:1337/api/restaurants', { name: 'Dolemon Sushi', description: 'Unmissable Japanese Sushi restaurant. The cheese and salmon makis are delicious', categories: [3], @@ -259,7 +259,7 @@ axios ::: request Example POST request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -325,7 +325,7 @@ let error = null; async function handleSubmit() { try { - const response = await axios.post('http://localhost:1337/restaurants', { + const response = await axios.post('http://localhost:1337/api/restaurants', { name: restaurantName, description: restaurantDescription, categories: restaurantCategories @@ -338,7 +338,7 @@ async function handleSubmit() { onMount(async () => { try { - const response = await axios.get('http://localhost:1337/categories'); + const response = await axios.get('http://localhost:1337/api/categories'); allCategories = response.data } catch(e) { error = e @@ -404,7 +404,7 @@ const headers = { async function handleSubmit() { try { - await fetch('http://localhost:1337/restaurants', { + await fetch('http://localhost:1337/api/restaurants', { method: "POST", headers: headers, body: JSON.stringify({ @@ -422,7 +422,7 @@ async function handleSubmit() { onMount(async () => { try { - const res = await fetch("http://localhost:1337/categories", { + const res = await fetch("http://localhost:1337/api/categories", { method: "GET", headers: headers, }).then(checkStatus) @@ -481,7 +481,7 @@ and the id of your category is `2`. import axios from 'axios'; axios - .put('http://localhost:1337/restaurants/2', { + .put('http://localhost:1337/api/restaurants/2', { categories: [2], }) .then(response => { @@ -497,7 +497,7 @@ axios ::: request Example PUT request with fetch ```js -fetch('http://localhost:1337/restaurants/2', { +fetch('http://localhost:1337/api/restaurants/2', { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/svelte.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/svelte.md index ab7ad6f433..58aaebada1 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/svelte.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/svelte.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [Svelte](https://svelte.dev) remains the same except that you will not fetch the same content. @@ -61,7 +61,7 @@ Be sure that you activated the `find` permission for the `restaurant` Collection ```js import axios from 'axios'; -axios.get('http://localhost:1337/restaurants').then(response => { +axios.get('http://localhost:1337/api/restaurants').then(response => { console.log(response); }); ``` @@ -74,7 +74,7 @@ axios.get('http://localhost:1337/restaurants').then(response => { ::: request Example GET request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -142,7 +142,7 @@ let error = null onMount(async () => { try { - const res = await axios.get('http://localhost:1337/restaurants'); + const res = await axios.get('http://localhost:1337/api/restaurants'); restaurants = res.data } catch (e) { error = e @@ -192,7 +192,7 @@ onMount(async () => { }; try { - const res = await fetch("http://localhost:1337/restaurants", { + const res = await fetch("http://localhost:1337/api/restaurants", { method: "GET", headers: { 'Content-Type': 'application/json' @@ -241,7 +241,7 @@ In this example a `japanese` category has been created which has the id: 3. import axios from 'axios'; axios - .post('http://localhost:1337/restaurants', { + .post('http://localhost:1337/api/restaurants', { name: 'Dolemon Sushi', description: 'Unmissable Japanese Sushi restaurant. The cheese and salmon makis are delicious', categories: [3], @@ -259,7 +259,7 @@ axios ::: request Example POST request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -325,7 +325,7 @@ let error = null; async function handleSubmit() { try { - const response = await axios.post('http://localhost:1337/restaurants', { + const response = await axios.post('http://localhost:1337/api/restaurants', { name: restaurantName, description: restaurantDescription, categories: restaurantCategories @@ -338,7 +338,7 @@ async function handleSubmit() { onMount(async () => { try { - const response = await axios.get('http://localhost:1337/categories'); + const response = await axios.get('http://localhost:1337/api/categories'); allCategories = response.data } catch(e) { error = e @@ -404,7 +404,7 @@ const headers = { async function handleSubmit() { try { - await fetch('http://localhost:1337/restaurants', { + await fetch('http://localhost:1337/api/restaurants', { method: "POST", headers: headers, body: JSON.stringify({ @@ -422,7 +422,7 @@ async function handleSubmit() { onMount(async () => { try { - const res = await fetch("http://localhost:1337/categories", { + const res = await fetch("http://localhost:1337/api/categories", { method: "GET", headers: headers, }).then(checkStatus) @@ -481,7 +481,7 @@ and the id of your category is `2`. import axios from 'axios'; axios - .put('http://localhost:1337/restaurants/2', { + .put('http://localhost:1337/api/restaurants/2', { categories: [2], }) .then(response => { @@ -497,7 +497,7 @@ axios ::: request Example PUT request with fetch ```js -fetch('http://localhost:1337/restaurants/2', { +fetch('http://localhost:1337/api/restaurants/2', { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/docs/developer-docs/latest/developer-resources/content-api/integrations/vue-js.md b/docs/developer-docs/latest/developer-resources/content-api/integrations/vue-js.md index 10b811caef..f4fa7d4d45 100644 --- a/docs/developer-docs/latest/developer-resources/content-api/integrations/vue-js.md +++ b/docs/developer-docs/latest/developer-resources/content-api/integrations/vue-js.md @@ -8,7 +8,7 @@ canonicalUrl: https://docs.strapi.io/developer-docs/latest/developer-resources/c !!!include(developer-docs/latest/developer-resources/content-api/snippets/integration-guide-not-updated.md)!!! -This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/restaurants). +This integration guide is following the [Quick Start Guide](/developer-docs/latest/getting-started/quick-start.md). We assume that you have fully completed its "Hands-on" path, and therefore can consume the API by browsing this [url](http://localhost:1337/api/restaurants). If you haven't gone through the Quick Start Guide, the way you request a Strapi API with [Vue.js](https://vuejs.org/) remains the same except that you will not fetch the same content. @@ -56,7 +56,7 @@ Be sure that you activated the `find` permission for the `restaurant` Collection ```js import axios from 'axios'; -axios.get('http://localhost:1337/restaurants').then(response => { +axios.get('http://localhost:1337/api/restaurants').then(response => { console.log(response); }); ``` @@ -69,7 +69,7 @@ axios.get('http://localhost:1337/restaurants').then(response => { ::: request Example GET request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -154,7 +154,7 @@ export default { }, async mounted () { try { - const response = await axios.get('http://localhost:1337/restaurants') + const response = await axios.get('http://localhost:1337/api/restaurants') this.restaurants = response.data } catch (error) { this.error = error; @@ -210,7 +210,7 @@ export default { }, async mounted () { try { - const response = await fetch("http://localhost:1337/restaurants", { + const response = await fetch("http://localhost:1337/api/restaurants", { method: 'GET', headers: this.headers, }).then(this.checkStatus) @@ -246,7 +246,7 @@ In this example a `japanese` category has been created which has the id: 3. import axios from 'axios'; axios - .post('http://localhost:1337/restaurants', { + .post('http://localhost:1337/api/restaurants', { name: 'Dolemon Sushi', description: 'Unmissable Japanese Sushi restaurant. The cheese and salmon makis are delicious', categories: [3], @@ -263,7 +263,7 @@ axios ::: request Example POST request with fetch ```js -fetch('http://localhost:1337/restaurants', { +fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -367,7 +367,7 @@ export default { }, async mounted() { try { - const response = await axios.get('http://localhost:1337/categories') + const response = await axios.get('http://localhost:1337/api/categories') this.allCategories = response.data; } catch (error) { this.error = error; @@ -378,7 +378,7 @@ export default { e.preventDefault(); try { - const response = await axios.post('http://localhost:1337/restaurants', this.modifiedData) + const response = await axios.post('http://localhost:1337/api/restaurants', this.modifiedData) console.log(response); } catch(error) { this.error = error; @@ -451,7 +451,7 @@ export default { }, async mounted() { try { - const allCategories = await fetch("http://localhost:1337/categories", { + const allCategories = await fetch("http://localhost:1337/api/categories", { method: 'GET', headers: this.headers, }).then(this.checkStatus) @@ -477,7 +477,7 @@ export default { e.preventDefault(); try { - const response = await fetch('http://localhost:1337/restaurants', { + const response = await fetch('http://localhost:1337/api/restaurants', { method: 'POST', headers: this.headers, body: JSON.stringify(this.modifiedData) @@ -516,7 +516,7 @@ and the id of your category is `2`. import axios from 'axios'; axios - .put('http://localhost:1337/restaurants/2', { + .put('http://localhost:1337/api/restaurants/2', { categories: [2], }) .then(response => { @@ -531,7 +531,7 @@ axios :::request Example PUT request with fetch ```js -fetch('http://localhost:1337/restaurants/2', { +fetch('http://localhost:1337/api/restaurants/2', { method: 'PUT', headers: { 'Content-Type': 'application/json', diff --git a/docs/developer-docs/latest/developer-resources/plugin-api-reference/admin-panel.md b/docs/developer-docs/latest/developer-resources/plugin-api-reference/admin-panel.md index 5c800f4d1f..127bdd887a 100644 --- a/docs/developer-docs/latest/developer-resources/plugin-api-reference/admin-panel.md +++ b/docs/developer-docs/latest/developer-resources/plugin-api-reference/admin-panel.md @@ -632,7 +632,7 @@ export default { cellFormatter: props =>
Object.keys(props).map(key =>

key

)
, }, ]; - }; + }); }, } ``` diff --git a/docs/developer-docs/latest/development/backend-customization/controllers.md b/docs/developer-docs/latest/development/backend-customization/controllers.md index 23b17e4166..75ee2a7922 100644 --- a/docs/developer-docs/latest/development/backend-customization/controllers.md +++ b/docs/developer-docs/latest/development/backend-customization/controllers.md @@ -63,7 +63,7 @@ module.exports = createCoreController('api::restaurant.restaurant', ({ strapi }) return this.transformResponse(sanitizedEntity); } -}); +})); ``` Each controller action can be an `async` or `sync` function. diff --git a/docs/developer-docs/latest/development/backend-customization/middlewares.md b/docs/developer-docs/latest/development/backend-customization/middlewares.md index f82f25be6a..63953834de 100644 --- a/docs/developer-docs/latest/development/backend-customization/middlewares.md +++ b/docs/developer-docs/latest/development/backend-customization/middlewares.md @@ -61,7 +61,7 @@ Middlewares are called different ways depending on their scope: - use `global::middleware-name` for application-level middlewares - use `api::api-name.middleware-name` for API-level middlewares -- use `pluigin:plugin-name.middleware-name` for plugin middlewares +- use `plugin::plugin-name.middleware-name` for plugin middlewares ::: tip To list all the registered middlewares, run `yarn strapi middlewares:list`. diff --git a/docs/developer-docs/latest/development/backend-customization/models.md b/docs/developer-docs/latest/development/backend-customization/models.md index 48815b28ac..e3714ad45b 100644 --- a/docs/developer-docs/latest/development/backend-customization/models.md +++ b/docs/developer-docs/latest/development/backend-customization/models.md @@ -27,10 +27,10 @@ Content-types in Strapi can be created: - with the [Content-Type Builder in the admin panel](/user-docs/latest/content-types-builder/introduction-to-content-types-builder.md), - or with [Strapi's interactive CLI `strapi generate`](/developer-docs/latest/developer-resources/cli/CLI.md#strapi-generate) command. -Creating a content-type with either method generates 2 files: +The content-types has the following models files: -- `schema.json` for the model's [schema](#model-schema) definition, -- `lifecycles.js` for [lifecycle hooks](#lifecycle-hooks). +- `schema.json` for the model's [schema](#model-schema) definition. (generated automatically, when creating content-type with either method) +- `lifecycles.js` for [lifecycle hooks](#lifecycle-hooks). This file must be created manually. These models files are stored in `./src/api/[api-name]/content-types/[content-type-name]/`, and any JavaScript or JSON file found in these folders will be loaded as a content-type's model (see [project structure](/developer-docs/latest/setup-deployment-guides/file-structure.md)). @@ -186,7 +186,7 @@ They can be unidirectional or bidirectional. In unidirectional relationships, on - A blog article belongs to a category. - Querying an article can retrieve its category, - - but querying a category won't retrieve the list of articles. + - but querying a category won't retrieve the owned article. ```js // ./src/api/[api-name]/content-types/article/schema.json @@ -208,7 +208,7 @@ They can be unidirectional or bidirectional. In unidirectional relationships, on - A blog article belongs to a category. - Querying an article can retrieve its category, - - and querying a category also retrieves its list of articles. + - and querying a category also retrieves its owned article. ```js // ./src/api/[api-name]/content-types/article/schema.json diff --git a/docs/developer-docs/latest/development/backend-customization/services.md b/docs/developer-docs/latest/development/backend-customization/services.md index 7ff4edb17a..4bc7c256bf 100644 --- a/docs/developer-docs/latest/development/backend-customization/services.md +++ b/docs/developer-docs/latest/development/backend-customization/services.md @@ -111,7 +111,7 @@ module.exports = createCoreController('api::restaurant.restaurant', ({ strapi }) const { userData } = ctx.body; // Store the new user in database. - const user = await strapi.service('api::users-permissions.user').add(userData); + const user = await strapi.service('plugin::users-permissions.user').add(userData); // Send an email to validate his subscriptions. strapi.service('api::email.email').send('welcome@mysite.com', user.email, 'Welcome', '...'); diff --git a/docs/developer-docs/latest/development/plugins/graphql.md b/docs/developer-docs/latest/development/plugins/graphql.md index 49b75dad29..4108782bed 100644 --- a/docs/developer-docs/latest/development/plugins/graphql.md +++ b/docs/developer-docs/latest/development/plugins/graphql.md @@ -5,7 +5,7 @@ description: Use a GraphQL endpoint in your Strapi project to fetch and mutate y # GraphQL -By default Strapi create [REST endpoints](/developer-docs/latest/developer-resources/content-api/content-api.md#api-endpoints) for each of your content types. With the GraphQL plugin, you will be able to add a GraphQL endpoint to fetch and mutate your content. +By default Strapi create [REST endpoints](/developer-docs/latest/developer-resources/database-apis-reference/rest-api.md#api-endpoints) for each of your content types. With the GraphQL plugin, you will be able to add a GraphQL endpoint to fetch and mutate your content. ## Usage @@ -273,7 +273,7 @@ You can also apply different parameters to the query to make more complex querie - `live`: Return only published entries (default) - `preview`: Return both draft entries & published entries -- `locale` (string): Define the locale to fetch the content for, if the [Internationalization (i18n) plugin](/developer-docs/latest/development/plugins/i18n.md) is installed and [localization is enabled for the content-type](/user-docs/latest/content-types-builder/creating-new-content-type.md#creating-a-new-content-type). +- `locale` (string): Define the locale to fetch the content for, if the [Internationalization (i18n) plugin](/developer-docs/latest/plugins/i18n.md) is installed and [localization is enabled for the content-type](/user-docs/latest/content-types-builder/creating-new-content-type.md#creating-a-new-content-type). - `:asc` or `:desc` - `where` (object): Define the filters to apply in the query. - ``: Equals. @@ -330,7 +330,7 @@ query { To simplify and automate the build of the GraphQL schema, we introduced the Shadow CRUD feature. It automatically generates the type definition, queries, mutations and resolvers based on your models. The feature also lets you make complex query with many arguments such as `limit`, `sort`, `start` and `where`. :::note -If you use a local plugin, the controller methods of your plugin are not created by default. In order for the Shadow CRUD to work you have to define them in your controllers for each of your models. You can find examples of controllers `findOne`, `find`, `create`, `update` and `delete` there : [Core controllers](/developer-docs/latest/development/backend-customization.md#controllers). +If you use a local plugin, the controller methods of your plugin are not created by default. In order for the Shadow CRUD to work you have to define them in your controllers for each of your models. You can find examples of controllers `findOne`, `find`, `create`, `update` and `delete` there : [Core controllers](/developer-docs/latest/development/backend-customization/controllers.md). ::: ### Example diff --git a/docs/developer-docs/latest/guides/auth-request.md b/docs/developer-docs/latest/guides/auth-request.md index 53583826c3..9fffff9c77 100644 --- a/docs/developer-docs/latest/guides/auth-request.md +++ b/docs/developer-docs/latest/guides/auth-request.md @@ -69,7 +69,7 @@ Finally create **2 users** with the following data. To login as a user your will have to follow the [login documentation](/developer-docs/latest/plugins/users-permissions.md#login). -Here is the API route for the authentication `/auth/local`. +Here is the API route for the authentication `/api/auth/local`. You have to request it in **POST**. @@ -80,7 +80,7 @@ You have to request it in **POST**. ```js import axios from 'axios'; -const { data } = await axios.post('http://localhost:1337/auth/local', { +const { data } = await axios.post('http://localhost:1337/api/auth/local', { identifier: 'reader@strapi.io', password: 'strapi', }); diff --git a/docs/developer-docs/latest/guides/unit-testing.md b/docs/developer-docs/latest/guides/unit-testing.md index 7748b337d3..3b5c488a4a 100644 --- a/docs/developer-docs/latest/guides/unit-testing.md +++ b/docs/developer-docs/latest/guides/unit-testing.md @@ -74,7 +74,7 @@ Those will inform `Jest` not to look for test inside the folder where it shouldn Test framework must have a clean empty environment to perform valid test and also not to interfere with current database. -Once `jest` is running it uses the `test` [environment](http://localhost:8080/documentation/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md) (switching `NODE_ENV` to `test`) +Once `jest` is running it uses the `test` [environment](/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md) (switching `NODE_ENV` to `test`) so we need to create a special environment setting for this purpose. Create a new config for test env `./config/env/test/database.json` and add the following value `"filename": ".tmp/test.db"` - the reason of that is that we want to have a separate sqlite database for tests, so our test will not touch real data. This file will be temporary, each time test is finished, we will remove that file that every time tests are run on the clean database. diff --git a/docs/developer-docs/latest/plugins/graphql.md b/docs/developer-docs/latest/plugins/graphql.md index 87899bc071..4c0b44526b 100644 --- a/docs/developer-docs/latest/plugins/graphql.md +++ b/docs/developer-docs/latest/plugins/graphql.md @@ -57,13 +57,15 @@ Please note the setting for GraphQL `tracing` as changed and has been moved to ` module.exports = { // graphql: { - endpoint: '/graphql', - shadowCRUD: true, - playgroundAlways: false, - depthLimit: 7, - amountLimit: 100, - apolloServer: { - tracing: false, + config: { + endpoint: '/graphql', + shadowCRUD: true, + playgroundAlways: false, + depthLimit: 7, + amountLimit: 100, + apolloServer: { + tracing: false, + }, }, }, }; @@ -122,7 +124,7 @@ input DocumentFiltersInput { or: [DocumentFiltersInput] not: DocumentFiltersInput } -​ + input DocumentInput { name: String description: String @@ -131,7 +133,7 @@ input DocumentInput { updatedAt: DateTime publishedAt: DateTime } -​ + type Document { name: String description: String @@ -140,21 +142,21 @@ type Document { updatedAt: DateTime publishedAt: DateTime } -​ + type DocumentEntity { id: ID attributes: Document } -​ + type DocumentEntityResponse { data: DocumentEntity } -​ + type DocumentEntityResponseCollection { data: [DocumentEntity!]! meta: ResponseCollectionMeta! } -​ + type DocumentRelationResponseCollection { data: [DocumentEntity!]! } @@ -192,23 +194,23 @@ Strapi provides a programmatic API to customize GraphQL, which allows: ```js // path: ./src/index.js -​ + module.exports = { -/** - * An asynchronous register function that runs before - * your application is initialized. - * - * This gives you an opportunity to extend code. - */ - register({ strapi }) => { + /** + * An asynchronous register function that runs before + * your application is initialized. + * + * This gives you an opportunity to extend code. + */ + register({ strapi }) { const extensionService = strapi.plugin('graphql').service('extension'); - ​ + extensionService.shadowCRUD('api::restaurant.restaurant').disable(); extensionService.shadowCRUD('api::category.category').disableQueries(); extensionService.shadowCRUD('api::address.address').disableMutations(); extensionService.shadowCRUD('api::document.document').field('locked').disable(); extensionService.shadowCRUD('api::like.like').disableActions(['create', 'update', 'delete']); - ​ + const extension = ({ nexus }) => ({ // Nexus types: [ @@ -222,13 +224,11 @@ module.exports = { plugins: [ nexus.plugin({ name: 'MyPlugin', - ​ onAfterBuild(schema) { console.log(schema); }, }), ], - ​ // GraphQL SDL typeDefs: ` type Article { @@ -244,14 +244,12 @@ module.exports = { }, }, }, - ​ resolversConfig: { 'Query.address': { auth: false, }, }, }); - ​ extensionService.use(extension); }, }; diff --git a/docs/developer-docs/latest/plugins/i18n.md b/docs/developer-docs/latest/plugins/i18n.md index 215ef5ea69..5cb07ea370 100644 --- a/docs/developer-docs/latest/plugins/i18n.md +++ b/docs/developer-docs/latest/plugins/i18n.md @@ -53,9 +53,9 @@ The i18n plugin adds new features to the [REST API](/developer-docs/latest/devel - a new [`locale`](#getting-localized-entries-with-the-locale-parameter) parameter to fetch content only for a specified locale - the ability to create a localized entry, either [from scratch](#creating-a-new-localized-entry) or [for an existing localized entry](#creating-a-localization-for-an-existing-entry) -### Getting localized entries with the `locale` parameter +### Getting localized entries with the `_locale` parameter -The `locale` [API parameter](/developer-docs/latest/developer-resources/database-apis-reference/rest-api.md#api-parameters) can be used to fetch entries only for a specified locale. It takes a locale code as value (see [full list of available locales](https://github.com/strapi/strapi/blob/master/packages/plugins/i18n/server/constants/iso-locales.json)). +The `_locale` [API parameter](/developer-docs/latest/developer-resources/database-apis-reference/rest-api.md#api-parameters) can be used to fetch entries only for a specified locale. It takes a locale code as value (see [full list of available locales](https://github.com/strapi/strapi/blob/master/packages/plugins/i18n/server/constants/iso-locales.json)). :::tip To fetch content for a locale, make sure it has been already [added to Strapi in the admin panel](/user-docs/latest/settings/managing-global-settings.md#configuring-internationalization-locales). @@ -64,12 +64,12 @@ The `locale` [API parameter](/developer-docs/latest/developer-resources/database The format for a GET request is the following: :::request -`GET /api/{content-type}?locale={locale-code}` +`GET /api/{content-type}?_locale={locale-code}` ::: -Use `all` as a value for the locale code, as in `http://localhost:1337/api/restaurants?locale=all`, to fetch entries for all locales that have been configured in the admin panel. +Use `all` as a value for the locale code, as in `http://localhost:1337/api/restaurants?_locale=all`, to fetch entries for all locales that have been configured in the admin panel. -If the `locale` parameter isn't defined, it will be set to the default locale. `en` is the default locale when the i18n plugin is installed, so by default a GET request to `http://localhost:1337/api/restaurants` will return the same response as a request to `http://localhost:1337/api/restaurants?locale=en`. +If the `_locale` parameter isn't defined, it will be set to the default locale. `en` is the default locale when the i18n plugin is installed, so by default a GET request to `http://localhost:1337/api/restaurants` will return the same response as a request to `http://localhost:1337/api/restaurants?_locale=en`. ::: tip Another locale can be [set as the default locale](/user-docs/latest/settings/managing-global-settings.md#adding-a-new-locale) in the admin panel. @@ -85,7 +85,7 @@ When the i18n plugin is installed, the response to requests can include fields t ::: request Example request -`GET http://localhost:1337/api/restaurants?locale=fr` +`GET http://localhost:1337/api/restaurants?_locale=fr` ::: @@ -711,6 +711,6 @@ The response returns the entry that has just been deleted. ## Configuration in production environments -A `STRAPI_PLUGIN_I18N_INIT_LOCALE_CODE` [environment variable](http://localhost:8080/documentation/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md-variables) can be configured to set the initialization locale for your environment. The value used for this variable should be a string (see [full list of available locales](https://github.com/strapi/strapi/blob/releases/v4/packages/plugins/i18n/server/constants/iso-locales.json)). +A `STRAPI_PLUGIN_I18N_INIT_LOCALE_CODE` [environment variable](/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.md#strapi-s-environment-variables) can be configured to set the initialization locale for your environment. The value used for this variable should be a string (see [full list of available locales](https://github.com/strapi/strapi/blob/releases/v4/packages/plugins/i18n/server/constants/iso-locales.json)). This is useful when a Strapi app is deployed in production, with the i18n plugin installed and enabled on your content types for the first time. On a fresh i18n plugin installation, `en` is the default locale. So if the database does not contain any locale, and no `STRAPI_PLUGIN_I18N_INIT_LOCALE_CODE` is set for the environment, the content of the content types with i18n enabled will be automatically migrated to the `en` locale. But if the `STRAPI_PLUGIN_I18N_INIT_LOCALE_CODE` is defined, then the content will be migrated to this locale. Using this environment variable saves you from having to manually update the locale for existing content entries. diff --git a/docs/developer-docs/latest/plugins/users-permissions.md b/docs/developer-docs/latest/plugins/users-permissions.md index a5cfc4b6c6..3c5827223a 100644 --- a/docs/developer-docs/latest/plugins/users-permissions.md +++ b/docs/developer-docs/latest/plugins/users-permissions.md @@ -41,7 +41,7 @@ On the right sidebar you will be able to see the URL related to this function. ### Update the default role -When you create a user without a role or if you use the `/auth/local/register` route, the `authenticated` role is given to the user. +When you create a user without a role or if you use the `/api/auth/local/register` route, the `authenticated` role is given to the user. To change the default role, go to the `Advanced settings` tab and update the `Default role for authenticated users` option. @@ -113,7 +113,7 @@ import axios from 'axios'; // Request API. // Add your own code here to customize or restrict how the public can register new users. axios - .post('http://localhost:1337/auth/local/register', { + .post('http://localhost:1337/api/auth/local/register', { username: 'Strapi user', email: 'user@strapi.io', password: 'strapiPassword', @@ -143,7 +143,7 @@ import axios from 'axios'; // Request API. axios - .post('http://localhost:1337/auth/local', { + .post('http://localhost:1337/api/auth/local', { identifier: 'user@strapi.io', password: 'strapiPassword', }) @@ -356,7 +356,7 @@ The use of `ngrok` is not needed. - **Client ID**: fill in the **App client id** (`5bd7a786qdupjmi0b3s10vegdt`) - **Client Secret**: fill in the **App client secret** (`19c5c78dsfsdfssfsdfhpdb4nkpb145vesdfdsfsffgh7vwd6g45jlipbpb`) - **Host URI (Subdomain)**: fill in the URL value that you copied earlier (`myapp67b50345-67b50b17-local.auth.eu-central-1.amazoncognito.com`) - - **The redirect URL to your front-end app**: if you are using strapi react-login [https://github.com/strapi/strapi-examples/tree/master/login-react/](https://github.com/strapi/strapi-examples/tree/master/login-react/) use `http://localhost:3000/connect/cognito/redirect` but if you do not yet have a front-end app to test your Cognito configuration you can then use the following URL `http://localhost:1337/auth/cognito/callback` + - **The redirect URL to your front-end app**: if you are using strapi react-login [https://github.com/strapi/strapi-examples/tree/master/login-react/](https://github.com/strapi/strapi-examples/tree/master/login-react/) use `http://localhost:3000/connect/cognito/redirect` but if you do not yet have a front-end app to test your Cognito configuration you can then use the following URL `http://localhost:1337/api/auth/cognito/callback` ::: @@ -747,7 +747,7 @@ import axios from 'axios'; // Request API. axios - .post('http://localhost:1337/auth/forgot-password', { + .post('http://localhost:1337/api/auth/forgot-password', { email: 'user@strapi.io', // user's email }) .then(response => { @@ -770,7 +770,7 @@ import axios from 'axios'; // Request API. axios - .post('http://localhost:1337/auth/reset-password', { + .post('http://localhost:1337/api/auth/reset-password', { code: 'privateCode', // code contained in the reset link of step 3. password: 'userNewPassword', passwordConfirmation: 'userNewPassword', @@ -802,7 +802,7 @@ import axios from 'axios'; // Request API. axios - .post(`http://localhost:1337/auth/send-email-confirmation`, { + .post(`http://localhost:1337/api/auth/send-email-confirmation`, { email: 'user@strapi.io', // user's email }) .then(response => { diff --git a/docs/developer-docs/latest/setup-deployment-guides/configurations/required/databases.md b/docs/developer-docs/latest/setup-deployment-guides/configurations/required/databases.md index 01c26bf932..1f4bb1d3be 100644 --- a/docs/developer-docs/latest/setup-deployment-guides/configurations/required/databases.md +++ b/docs/developer-docs/latest/setup-deployment-guides/configurations/required/databases.md @@ -38,7 +38,7 @@ The `connection.connection` object found in `./config/database.js` is used to pa | `host` | Database host name. Default value: `localhost`. | `String` | | `port` | Database port | `Integer` | | `database` | Database name. | `String` | -| `username` | Username used to establish the connection | `String` | +| `user` | Username used to establish the connection | `String` | | `password` | Password used to establish the connection | `String` | | `timezone` | Set the default behavior for local time. Default value: `utc` [Timezone options](https://www.php.net/manual/en/timezones.php) | `String` | | `schema` | Set the default database schema. **Used only for Postgres DB.** | `String` | @@ -142,7 +142,7 @@ module.exports = ({ env }) => ({ client: 'mysql', connection: { host: env('DATABASE_HOST', '127.0.0.1'), - port: env.int('DATABASE_PORT', 5432), + port: env.int('DATABASE_PORT', 3306), database: env('DATABASE_NAME', 'strapi'), user: env('DATABASE_USERNAME', 'strapi'), password: env('DATABASE_PASSWORD', 'strapi'), diff --git a/docs/developer-docs/latest/setup-deployment-guides/deployment.md b/docs/developer-docs/latest/setup-deployment-guides/deployment.md index b6614a60e0..7764d4040d 100644 --- a/docs/developer-docs/latest/setup-deployment-guides/deployment.md +++ b/docs/developer-docs/latest/setup-deployment-guides/deployment.md @@ -24,8 +24,8 @@ To provide the best possible environment for Strapi there are a few requirements - At least 2 GB of RAM (Moderately recommended 4) - Minimum required storage space recommended by your OS or 32 GB of **free** space - A supported database version - - MySQL >= 5.6 - - MariaDB >= 10.1 + - MySQL >= 5.7.8 + - MariaDB >= 10.2.7 - PostgreSQL >= 10 - SQLite >= 3 - A supported operating system diff --git a/docs/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/azure.md b/docs/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/azure.md index 60110308de..d5a0a9f456 100644 --- a/docs/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/azure.md +++ b/docs/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/azure.md @@ -194,8 +194,8 @@ For Azure managed databases you can use the following: Likewise you can use any of the following installed locally on the virtual machine: -- MySQL >= 5.6 -- MariaDB >= 10.1 +- MySQL >= 5.7.8 +- MariaDB >= 10.2.7 - PostgreSQL >= 10 - SQLite >= 3 diff --git a/docs/developer-docs/latest/setup-deployment-guides/installation/cli.md b/docs/developer-docs/latest/setup-deployment-guides/installation/cli.md index d02f6c22a9..79990bb100 100644 --- a/docs/developer-docs/latest/setup-deployment-guides/installation/cli.md +++ b/docs/developer-docs/latest/setup-deployment-guides/installation/cli.md @@ -21,8 +21,8 @@ A database is also required for any Strapi project. Strapi currently supports th | ---------- | --------------- | | SQLite | 3 | | PostgreSQL | 10 | -| MySQL | 5.6 | -| MariaDB | 10.1 | +| MySQL | 5.7.8 | +| MariaDB | 10.2.7 | ## Creating a Strapi project