res.json type fixes
This commit is contained in:
@@ -50,11 +50,6 @@ let {reg, getTemplateRegistration, writeRegistration, readRegistration, checkReg
|
||||
|
||||
const {setupEmojis} = require("../src/m2d/actions/setup-emojis")
|
||||
|
||||
function die(message) {
|
||||
console.error(message)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
async function suggestWellKnown(serverUrlPrompt, url, otherwise) {
|
||||
try {
|
||||
var json = await fetch(`${url}/.well-known/matrix/client`).then(res => res.json())
|
||||
@@ -80,6 +75,7 @@ async function validateHomeserverOrigin(serverUrlPrompt, url) {
|
||||
return e.message
|
||||
}
|
||||
try {
|
||||
/** @type {any} */
|
||||
var json = await res.json()
|
||||
if (!Array.isArray(json?.versions) || !json.versions.includes("v1.11")) {
|
||||
return `OOYE needs Matrix version v1.11, but ${url} doesn't support this`
|
||||
@@ -130,7 +126,7 @@ function defineEchoHandler() {
|
||||
initial: "6693"
|
||||
})
|
||||
portResponse.socket = +portResponse.socket || portResponse.socket // convert to number if numeric
|
||||
|
||||
|
||||
const app = createApp()
|
||||
app.use(defineEchoHandler())
|
||||
const server = createServer(toNodeListener(app))
|
||||
|
||||
@@ -22,6 +22,7 @@ async function fetchMessage(messageID) {
|
||||
throw new Error(`Failed to connect to PK API: ${networkError.toString()}`)
|
||||
}
|
||||
if (!res.ok) throw new Error(`PK API returned an error: ${await res.text()}`)
|
||||
/** @type {any} */
|
||||
const root = await res.json()
|
||||
if (!root.member) throw new Error(`PK API didn't return member data: ${JSON.stringify(root)}`)
|
||||
return root
|
||||
|
||||
@@ -72,6 +72,7 @@ async function mreq(method, url, bodyIn, extra = {}) {
|
||||
}, extra)
|
||||
|
||||
const res = await fetch(baseUrl + url, opts)
|
||||
/** @type {any} */
|
||||
const root = await res.json()
|
||||
|
||||
if (!res.ok || root.errcode) {
|
||||
|
||||
Reference in New Issue
Block a user