Skip to content

Commit e86a3a0

Browse files
committed
Declare return types for API calls
1 parent 72f391f commit e86a3a0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

client/src/services/Api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class ApiService {
2222
this.client = client
2323
}
2424

25-
get(path: string): Promise<Array<Object>> {
25+
get(path: string): Promise<Object> | Promise<Array<Object>> {
2626
return this.client.get(path).then(response => response.data)
2727
}
2828

2929
post(path: string, payload: Object): Promise<Object> {
3030
return this.client.post(path, payload).then(response => response.data)
3131
}
3232

33-
patch(path: string, payload: Object) {
33+
patch(path: string, payload: Object): Promise<Object> {
3434
return this.client.patch(path, payload).then(response => response.data)
3535
}
3636

client/src/services/posts.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// @flow
22

3-
import type { Posts, Post } from '../types/posts'
3+
import type { Post, Posts } from '../types/posts'
44

55
import service from './Api'
66

7-
export function fetchPostsFromApi(): Promise<Posts> {
7+
export function fetchPostsFromApi(): Promise<Post> | Promise<Posts> {
88
return service.get('/posts')
99
}
1010

0 commit comments

Comments
 (0)