movie.api.js 1021 Bytes
Newer Older
1
2
3
import axios from "axios";
import { baseUrl, TMDBUrl } from "../utils/baseUrl";

Kim, Subin's avatar
Kim, Subin committed
4
5
6
const getfromTM = async (category) => {
    const response = await axios.get(`${baseUrl}/api/movie/showmovie/${category}`)
    return response.data
7
8
}

Kim, Subin's avatar
Kim, Subin committed
9
10
11
12
13
14
15
16
17
18
const getAllfromTM = async () => {
    const payload = {
        params: {
            pageNum: 1
        }
    }
    const { data } = await axios.get(`${baseUrl}/api/movie/all`, payload)
    return data
}

19
20
const submit = async (movieId) => {
    const { data } = await axios.post(`${baseUrl}/api/movie/${movieId}`)
Kim, Subin's avatar
Kim, Subin committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    return data
}

const remove = async (movieId) => {
    const { data } = await axios.delete(`${baseUrl}/api/movie/${movieId}`)
    return data
}

const search = async (title) => {
    const payload = {
        params: {
            title: title
        }
    }
    const { data } = await axios.get(`${baseUrl}/api/movie/search`, payload)
    return data
37
38
39
}

const movieApi = {
Kim, Subin's avatar
Kim, Subin committed
40
    getfromTM,
Kim, Subin's avatar
Kim, Subin committed
41
42
43
44
    getAllfromTM,
    submit,
    remove,
    search
45
46
47
}

export default movieApi