feat: add formatCode API client
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
import { languageToId } from "./templates"
|
import { languageToId } from "./templates"
|
||||||
import { Code, Submission } from "./types"
|
import { Code, LANGUAGE, Submission } from "./types"
|
||||||
|
|
||||||
function encode(string?: string) {
|
function encode(string?: string) {
|
||||||
return btoa(String.fromCharCode(...new TextEncoder().encode(string ?? "")))
|
return btoa(String.fromCharCode(...new TextEncoder().encode(string ?? "")))
|
||||||
@@ -133,3 +133,8 @@ export async function debug(code: string, inputs: string[]) {
|
|||||||
})
|
})
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function formatCode(code: string, language: LANGUAGE) {
|
||||||
|
const res = await api.post("/format", { code, language })
|
||||||
|
return res.data.code as string
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user