If you go to the URL below, the data from the GitHub repository will be returned as a Json file. Could you tell me how to define the type for items with multiple objects in the array?
https://api.github.com/repositories/354726603/contents/articles
I thought I could refer to this article, but the data returned is [{}, {}, {}...]
and the number of data returned is expected to increase in the future.
When that happens, I don't know how to define the type.
Could you please help me?Please.
type Articles={
id:string;
name —string;
age:number;
created_at:number;
updated_at:number;
};
I wrote it in my own way. I wrote the definition of the type article
and the image that it was arranged.
Now I think I can define the type itself.
typeArticle={
name —string;
sha —string;
size:number;
url:string;
html_url:string;
git_url:string;
download_url:string;
type:string;
_links:{
self:string;
git:string;
html:string;
}
};
constzennArticles: Article[] = wait fetch("https://api.github.com/repos/wimpykid719/zenn-content/contents/articles/")
.then(res=>{
return res.json();
})
.catch(err=>{
console.log(err);
});
© 2024 OneMinuteCode. All rights reserved.