@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
32 lines • 1.25 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = require("react");
const useProject_1 = __importDefault(require("../projects/useProject"));
const axios_1 = __importDefault(require("../../config/axios"));
function useFetchCommentByForeignId() {
const { projectId } = (0, useProject_1.default)();
const fetchCommentByForeignId = (0, react_1.useCallback)(async ({ foreignId, include }) => {
if (!projectId) {
throw new Error("No project specified");
}
if (!foreignId) {
throw new Error("No foreign ID passed");
}
const params = {
foreignId,
};
if (include) {
params.include = Array.isArray(include) ? include.join(',') : include;
}
const response = await axios_1.default.get(`/${projectId}/comments/by-foreign-id`, {
params,
});
return response.data;
}, [projectId]);
return fetchCommentByForeignId;
}
exports.default = useFetchCommentByForeignId;
//# sourceMappingURL=useFetchCommentByForeignId.js.map