xiaohongshu
xiaohongshu
axios
Promise-based HTTP client for making requests from browser and Node.js
Full skill instructions
Axios is a promise-based HTTP client for the browser and Node.js. It provides a simple API for making HTTP requests and handling responses.
import axios from "axios";
// Promise-based
axios
.get("/user?ID=12345")
.then((response) => console.log(response.data))
.catch((error) => console.error(error));
// Async/await
async function getUser() {
try {
const response = await axios.get("/user?ID=12345");
console.log(response.data);
} catch (error) {
console.error(error);
}
}
axios
.post("/user", {
firstName: "John",
lastName: "Doe",
})
.then((response) => console.log(response.data))
.catch((error) => console.error(error));
const api = axios.create({
baseURL: "https://api.example.com",
timeout: 1000,
headers: { "X-Custom-Header": "foobar" },
});
// Use the instance
api.get("/users").then((response) => console.log(response.data));
axios({
method: "post",
url: "/user/12345",
data: {
firstName: "Fred",
lastName: "Flintstone",
},
headers: {
"Content-Type": "application/json",
Authorization: "Bearer token",
},
});
function getUserAccount() {
return axios.get("/user/12345");
}
function getUserPermissions() {
return axios.get("/user/12345/permissions");
}
Promise.all([getUserAccount(), getUserPermissions()]).then(
([account, permissions]) => {
console.log("Account:", account.data);
console.log("Permissions:", permissions.data);
},
);
axios.get("/user/12345").catch(function (error) {
if (error.response) {
// Server responded with error status
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// Request was made but no response received
console.log(error.request);
} else {
// Error in request setup
console.log("Error", error.message);
}
});
axios.get("/user/12345", {
validateStatus: function (status) {
return status < 500; // Resolve only if status < 500
},
});
axios.interceptors.request.use(
(config) => {
// Add auth token to headers
const token = localStorage.getItem("token");
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
},
(error) => {
return Promise.reject(error);
},
);
axios.interceptors.response.use(
(response) => {
// Transform response data
return response.data;
},
(error) => {
// Handle common errors
if (error.response?.status === 401) {
// Redirect to login
window.location.href = "/login";
}
return Promise.reject(error);
},
);
const api = axios.create({ baseURL: "/api" });
api.interceptors.response.use(undefined, async (error) => {
if (error.response?.status === 401) {
await refreshToken();
return api(error.config); // Retry original request
}
throw error;
});
const config = {
url: "/user",
method: "get",
baseURL: "https://api.example.com",
headers: { "X-Requested-With": "XMLHttpRequest" },
params: { ID: 12345 },
data: { firstName: "John" },
timeout: 5000,
responseType: "json",
withCredentials: false,
validateStatus: (status) => status >= 200 && status < 300,
};
const formData = new FormData();
formData.append("file", fileInput.files[0]);
formData.append("username", "john");
axios.post("/upload", formData, {
headers: {
"Content-Type": "multipart/form-data",
},
});
axios.get("/download/file", {
onDownloadProgress: (progressEvent) => {
const percentCompleted = Math.round(
(progressEvent.loaded * 100) / progressEvent.total,
);
console.log(`Download: ${percentCompleted}%`);
},
});
Axios responses contain:
{
data: {}, // Server response data
status: 200, // HTTP status code
statusText: 'OK', // HTTP status message
headers: {}, // Response headers
config: {}, // Request config
request: {} // Request object
}
import axios, { AxiosResponse } from "axios";
interface User {
id: number;
name: string;
email: string;
}
const response: AxiosResponse<User> = await axios.get<User>("/user/123");
const user: User = response.data;
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience