Files
iNaturalistReactNative/src/api/comments.js
Amanda Bullington 21b9cc6a97 Update Eslint to support TypeScript (#1419)
* Add typescript parser and fix Flow errors in JS files

* Uninstall packages from react-native/eslint-config

* Fix all flow errors (or ignore them for unknowns
2024-04-18 21:35:26 -07:00

53 lines
1.0 KiB
JavaScript

// @flow
import inatjs from "inaturalistjs";
import Comment from "realmModels/Comment";
import handleError from "./error";
const PARAMS = {
fields: Comment.COMMENT_FIELDS
};
const createComment = async (
params: Object = {},
opts: Object = {}
): Promise<?Object> => {
try {
const { results } = await inatjs.comments.create( { ...PARAMS, ...params }, opts );
return results;
} catch ( e ) {
return handleError( e );
}
};
const updateComment = async (
params: Object = {},
opts: Object = {}
): Promise<?Object> => {
try {
const { results } = await inatjs.comments.update( { ...PARAMS, ...params }, opts );
return results;
} catch ( e ) {
return handleError( e );
}
};
const deleteComments = async (
id: number,
opts: Object = {}
): Promise<?Object> => {
try {
const { results } = await inatjs.comments.delete( { id }, opts );
return results;
} catch ( e ) {
return handleError( e );
}
};
export {
createComment,
deleteComments,
updateComment
};