axios post typescript example
Example 1: Using axios send a GET request to the address:
axios({
method: 'post',
url: '/user/12345',
data: {
firstName: 'Fred',
lastName: 'Flintstone'
}
});
Example 2: making axios call with headers
axios.post('url', {"body":data}, {
headers: {
'Content-Type': 'application/json'
}
}
)
Example 3: axios typescript
axios.request<ServerData>({
url: 'https://example.com/path/to/data',
transformResponse: (r: ServerResponse) => r.data
}).then((response) => {
const { data } = response
})