Added try/catch to mastodon micro-service
This commit is contained in:
parent
b6630790cc
commit
2e4af394f9
|
@ -4,12 +4,22 @@ import { Request, Response } from 'express'
|
|||
|
||||
export default class MastodonController extends MastodonService {
|
||||
public fetchMastodonProfile = async (req: Request, res: Response) => {
|
||||
try{
|
||||
const data = await this.getMastodonProfile()
|
||||
return res.send(makeResponse(data))
|
||||
}
|
||||
catch (err: any){
|
||||
res.send(makeResponse(err.message, {}, 'Failed', true))
|
||||
}
|
||||
}
|
||||
|
||||
public fetchMastodonStatuses = async (req: Request, res: Response) => {
|
||||
try {
|
||||
const data = await this.getMastodonStatuses()
|
||||
return res.send(makeResponse(data))
|
||||
}
|
||||
catch (err: any) {
|
||||
res.send(makeResponse(err.message, {}, 'Failed', true))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,10 @@ export default class MastodonService {
|
|||
|
||||
public getMastodonStatuses = async () => {
|
||||
const { data } = await axiosInstance.get(
|
||||
'https://fosstodon.org/api/v1/accounts/109612266657666903/statuses'
|
||||
'https://fosstodon.org/api/v1/accounts/109612266657666903/statuses',
|
||||
{
|
||||
timeout: 10000
|
||||
}
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue