movie.api.js 1.04 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
29
30
31
32
33
34
35
36
37
    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)
    console.log("server recive==", data)
    return data
38
39
40
}

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

export default movieApi