Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Bruno Predot
/
tmdb_test
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Bruno Predot
2025-04-25 15:09:09 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
19452a881fa81bb07aadd0c861b6b305a9f827e9
19452a88
1 parent
80a65ddf
Ajout fonction fetchMovieDetails() dans composable useTMDB.
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletions
composables/tMDB.ts
composables/tMDB.ts
View file @
19452a8
...
...
@@ -44,5 +44,24 @@ export const useTMDB = function() {
}
};
return
{
fetchPopularMovies
,
searchMovies
}
/**
* Fetch movie details by id.
* @param id
*/
const
fetchMovieDetails
=
async
(
id
:
number
)
=>
{
try
{
const
response
=
await
fetch
(
`
${
apiUrl
}
/movie/
${
id
}
?api_key=
${
apiKey
}
&language=fr-FR`
,
);
if
(
!
response
.
ok
)
{
console
.
error
(
"An error occurred when fetching movie details:"
);
}
else
{
return
await
response
.
json
();
}
}
catch
(
error
)
{
console
.
error
(
"Error fetching details:"
,
error
);
}
};
return
{
fetchPopularMovies
,
searchMovies
,
fetchMovieDetails
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment