Skip to content

update a paragraph #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ include::finish/src/main/frontend/src/Components/ArtistTable.js[]
[role="edit_command_text"]
Add the [hotspot=axios-library]`axios` library and the [hotspot=get-posts]`GetArtistsInfo()` function.

The [hotspot=axios]`axios` HTTP call is used to read the artist JSON that contains the data from the sample JSON file in the `resources` directory. When a response is successful, the state of the system changes by assigning [hotspot=response-data]`response.data` to [hotspot=posts]`posts`. The [hotspot=convert-data]`convertData` function manipulates the JSON data to allow it to be accessed by the `ReactTable`. You will notice the [hotspot=spread-one hotspot=spread-two]`object spread syntax` that the `convertData` function uses, which is a relatively new sytnax made for simplicity. To learn more about it, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals[Spread in object literals^].
The [hotspot=axios]`axios` HTTP call is used to read the artist JSON that contains the data from the sample JSON file in the `resources` directory. When a response is successful, the state of the system changes by assigning [hotspot=response-data]`response.data` to [hotspot=posts]`posts`. The [hotspot=for-artists]`artists` and their `albums` JSON data are manipulated to allow them to be accessed by the `ReactTable`. You will notice the [hotspot=spread-one]`...rest` or [hotspot=spread-two]`...album` object spread syntax is a relatively new sytnax made for simplicity. To learn more about it, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#Spread_in_object_literals[Spread in object literals^].

ifdef::cloud-hosted[]
Finally, run the following command to update the URL to access the ***artists.json*** in the ***ArtistTable.js*** file:
Expand Down
6 changes: 2 additions & 4 deletions finish/src/main/frontend/src/Components/ArtistTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ export function ArtistTable() {
// tag::axios[]
const response = await axios.get('http://localhost:9080/artists')
// end::axios[]
// tag::then-method[]
.then(response => {
// tag::response-data[]
const artists = response.data;
// end::response-data[]
// tag::for-artists[]
for (const artist of artists) {
// tag::spread-one[]
const { albums, ...rest } = artist;
// end::spread-one[]
// tag::convert-data[]
for (const album of albums) {
//tag::setState[]
setPosts([...posts, { ...rest, ...album }]);
Expand All @@ -42,9 +41,8 @@ export function ArtistTable() {
posts.push({ ...rest, ...album });
// end::spread-two[]
}
// end::convert-data[]
};
// end::then-method[]
// end::for-artists[]
}).catch(error => { console.log(error); });
};
// end::get-posts[]
Expand Down