Basic Usage of superagent
5/10/23Less than 1 minute
Updated on 2024.05.06
It is recommended to use axios
Sending Post Requests with superagent
- JSON type
superagent
.post("/api/pet")
.send({ name: "Manny", species: "cat" }) // sends a JSON post body
.set("X-API-Key", "foobar")
.set("accept", "json")
.end((err, res) => {
// Calling the end function will send the request
});- Form type
superagent
.post("/api/pet")
.send({ name: "Manny", species: "cat" })
.type("form")
.end((err, res) => {
// Calling the end function will send the request
});AI Translation | AI 翻译
This article was translated from Chinese to English by AI. If there are any inaccuracies, please refer to the original Chinese version.
本文由 AI 辅助从中文翻译为英文。如遇不准确之处,请以中文原版为准。
