34 lines
793 B
TypeScript
34 lines
793 B
TypeScript
import { AxiosError } from "axios"
|
|
import { client } from "./config";
|
|
import { POST_REVIEW_LOCATION_URI } from "../constants/api";
|
|
|
|
const initialState: IEmptyResponseState = {
|
|
data: null,
|
|
error: AxiosError
|
|
}
|
|
|
|
interface postReviewLocationReq {
|
|
submitted_by: number,
|
|
comments: string,
|
|
score: number,
|
|
is_from_critic: boolean,
|
|
is_hided: boolean,
|
|
location_id: number
|
|
}
|
|
|
|
async function postReviewLocation(req: postReviewLocationReq) {
|
|
const newState = { ...initialState };
|
|
try {
|
|
const response = await client({ method: 'POST', url: POST_REVIEW_LOCATION_URI, data: req, withCredentials: true})
|
|
newState.data = response.data
|
|
newState.error = null
|
|
return newState
|
|
} catch (error) {
|
|
newState.error = error
|
|
throw(error)
|
|
}
|
|
}
|
|
|
|
export {
|
|
postReviewLocation
|
|
} |