feat [both]: tmdb calls from django

This commit is contained in:
Alice 2022-05-30 00:18:09 +02:00
parent fe717f94f1
commit b40916c7f4
6 changed files with 39 additions and 11 deletions

View file

@ -132,7 +132,7 @@
<!-- doc : https://bluefantail.github.io/bulma-list/ -->
<div class="list has-visible-pointer-controls">
<div
v-for="(foundFilm, index) of foundFilms?.results"
v-for="(foundFilm, index) of foundFilms"
:key="foundFilm.id"
class="list-item"
>
@ -144,7 +144,7 @@
<div class="list-item-content">
<div class="list-item-title">{{ foundFilm.title }}</div>
<div class="list-item-description">
{{ foundFilm.release_date }}
{{ foundFilm.releaseDate }}
</div>
</div>
<div class="list-item-controls">
@ -176,7 +176,7 @@ const film = useModel<Film>("modelValue", { type: "object" })
const foundFilms = ref()
// https://developers.themoviedb.org/3/getting-started/images
const image = computed(() => (index: number) => {
return `https://image.tmdb.org/t/p/w500${foundFilms.value?.results[index].poster_path}`
return `https://image.tmdb.org/t/p/w500${foundFilms.value[index]?.posterPath}`
})
const durationNoSecond = computed<string>({
@ -187,12 +187,8 @@ const durationNoSecond = computed<string>({
})
async function findFilm() {
foundFilms.value = await $fetch("https://api.themoviedb.org/3/search/movie", {
params: {
api_key: "INSERT API KEY HERE",
language: "fr-FR",
query: title.value,
},
})
foundFilms.value = (
await apiGet("tmdb/search/", { query: film.value.title })
).data.value
}
</script>

View file

@ -1,9 +1,11 @@
from django.urls import include, path
from rest_framework import routers
from .views.std_views import FilmViewSet
from .views.tmdb_views import TmdbViewSet
router = routers.DefaultRouter()
router.register(r"films", FilmViewSet)
router.register(r"tmdb", TmdbViewSet, "tmdb")
# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.

View file

File diff suppressed because one or more lines are too long

View file

@ -3,3 +3,4 @@ djangorestframework==3.13.1
django-cors-headers==3.11.0
djangorestframework-camel-case==1.3.0
getconf~=1.11.1
tmdbv3api~=1.7.6

View file

@ -16,4 +16,7 @@ Including another URLconf
from django.contrib import admin
from django.urls import path, include
urlpatterns = [path("admin/", admin.site.urls), path("api/", include("myapi.urls"))]
urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include("myapi.urls")),
]