Thanks for taking the time to answer to my question, I misexplained myself :
import { Component } from '@angular/core';
const parseJSON = (resp: { json: () => any; }) => (resp.json ? resp.json() : resp);
// Checks if a network request came back fine, and throws an error if not
;
const headers = {
'Content-Type': 'application/json',
};
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent {
contenu = [];
error: unknown;
async ngOnInit() {
try {
const contenu = await fetch('http://localhost:1337/api/contents', {
method: 'GET',
headers: headers,
})
.then(parseJSON);
this.contenu = contenu.data;
console.log(contenu.data);
} catch (error) {
this.error = error;
}
}
}
Array(1)
0:
attributes: {testcontenu: 'test', contenu: 'testtestestes', createdAt: '2022-05-03T11:38:40.330Z', updatedAt: '2022-05-03T11:38:41.250Z', publishedAt: '2022-05-03T11:38:41.248Z'}
id: 1
[[Prototype]]: Object
length: 1
[[Prototype]]: Array(0)
And this is the answer I’m getting, on discord they suggested me to map it like this :
result = contenu.data.map(e => e.attributes)
but I can’t seem to put it on my front that looks like this :
<h1 *ngFor="let contenu of contenu">{{ contenu['attributes.testtest'] }}</h1>
<p>
<markdown *ngFor="let contenu of contenu">
{{ contenu['attributes.testcontenu'] }}
</markdown>
I’m just trying to get the data out of my array working on the dynamic angular app, so this is kind of why I was looking at an available starter that would explain how to get them back on Strap v4.