📝 Refactors loads of docs

⚰️ Death by Documentation
This commit is contained in:
Alicia Sykes
2022-01-22 20:43:38 +00:00
parent 6cc711ae23
commit 4278764101
10 changed files with 208 additions and 93 deletions

View File

@@ -257,12 +257,22 @@ import { widgetApiEndpoints } from '@/utils/defaults';
export default {
mixins: [WidgetMixin],
data() {
return {};
return {
results: null,
};
},
computed: {
endpoint() {
return `${widgetApiEndpoints.myApi}/something`;
},
},
computed: {},
methods: {
fetchData() {
// TODO: Make Data Request
this.makeRequest(this.endpoint).then(this.processData);
},
processData(data) {
// Do processing any here, and set component data
this.results = data;
},
},
};
@@ -333,16 +343,7 @@ Under the `methods` block, we'll create a function called `fetchData`, here we c
```javascript
fetchData() {
axios.get(this.endpoint)
.then((response) => {
this.processData(response.data);
})
.catch((dataFetchError) => {
this.error('Unable to fetch data', dataFetchError);
})
.finally(() => {
this.finishLoading();
});
this.makeRequest(this.endpoint, this.headers).then(this.processData);
},
```