movie.api.js 1.01 KB
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
    return data
}

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

Kim, Subin's avatar
Kim, Subin committed
29
const search = async ({ type, keyword }) => {
Kim, Subin's avatar
Kim, Subin committed
30
31
    const payload = {
        params: {
Kim, Subin's avatar
Kim, Subin committed
32
            keyword
Kim, Subin's avatar
Kim, Subin committed
33
34
        }
    }
Kim, Subin's avatar
Kim, Subin committed
35
    const { data } = await axios.get(`${baseUrl}/api/movie/search/${type}`, payload)
Kim, Subin's avatar
Kim, Subin committed
36
    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