fox-foxivich
fox-foxivich
TTCTheo's Typesafe Cult
Created by Gaden on 6/22/2023 in #questions
Upload image from server to uploadthing
But like didn’t you mean the upload button on the frontend side? On the frontend side you can’t preupload the file there
10 replies
TTCTheo's Typesafe Cult
Created by Gaden on 6/22/2023 in #questions
Upload image from server to uploadthing
No, it’s not possible due to security
10 replies
TTCTheo's Typesafe Cult
Created by s☻d on 6/21/2023 in #questions
dumb async questions
you can do something like that
import axios from "axios"

const getSomeResponse = () => {
return axios
.get("https://www.grepper.com/api/get_answers_1.php?v=4&s=axios&u=1300987")
.then((response) => response.data)
}

const yourCode = async () => {
let yourResponse

try {
const response = await getSomeResponse()
yourResponse = response
} catch (error) {
console.error(error)
}
}

const yourCodeWithThens = () => {
let yourResponse

getSomeResponse()
.then((response) => {
yourResponse = response
})
.catch((error) => {
console.error(error)
})
}
import axios from "axios"

const getSomeResponse = () => {
return axios
.get("https://www.grepper.com/api/get_answers_1.php?v=4&s=axios&u=1300987")
.then((response) => response.data)
}

const yourCode = async () => {
let yourResponse

try {
const response = await getSomeResponse()
yourResponse = response
} catch (error) {
console.error(error)
}
}

const yourCodeWithThens = () => {
let yourResponse

getSomeResponse()
.then((response) => {
yourResponse = response
})
.catch((error) => {
console.error(error)
})
}
just create a variable in the scope above and in the then scope assign your response to the variable. And also there's try catch for errors with async/await and there's .catch() method in the regular promises
5 replies