//native
/**
* Upload an image
* Upload an image to your ReadMe project.
*/
export async function main(auth: RT.Readme, body: Body, resize_height?: string | undefined) {
const url = new URL(`https://api.readme.com/v2/images`)
for (const [k, v] of [['resize_height', resize_height]]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const formData = new FormData()
for (const [k, v] of Object.entries(body)) {
if (v !== undefined && v !== '') {
formData.append(k, String(v))
}
}
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
body: formData
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export interface Body {
file?: unknown
}
Submitted by hugo697 235 days ago