ok maybe a little
This commit is contained in:
parent
a609dcef99
commit
501768a31d
1 changed files with 7 additions and 2 deletions
9
index.js
9
index.js
|
@ -1,6 +1,7 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
import logRequest from "./logger.js";
|
import logRequest from "./logger.js";
|
||||||
import { parse } from "node-html-parser";
|
import { parse } from "node-html-parser";
|
||||||
|
import { format } from "util";
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
FUCKING_ENDPOINT:
|
FUCKING_ENDPOINT:
|
||||||
|
@ -27,14 +28,18 @@ app.get("/*/status/*", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
twitter_res = await fetch(target);
|
twitter_res = await fetch(target);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
returnres.status(502).send(err.message);
|
return res
|
||||||
|
.status(502)
|
||||||
|
.send("Error from Twitter API: " + format("%s", err));
|
||||||
}
|
}
|
||||||
if (twitter_res.status == 200) {
|
if (twitter_res.status == 200) {
|
||||||
let body;
|
let body;
|
||||||
try {
|
try {
|
||||||
body = await twitter_res.json();
|
body = await twitter_res.json();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return res.status(502).send(err.message);
|
return res
|
||||||
|
.status(502)
|
||||||
|
.send("Error from Twitter API: " + format("%s", err));
|
||||||
}
|
}
|
||||||
let html = parse(body.html);
|
let html = parse(body.html);
|
||||||
let block = html.firstChild;
|
let block = html.firstChild;
|
||||||
|
|
Loading…
Reference in a new issue