curl to axios, explained
-H flags become the headers object, -d becomes data, -u becomes the auth object, and URL-encoded forms are converted to URLSearchParams. The output uses the modern async/await style with ES module imports.
Example
curl -X PATCH https://api.example.com/users/7 \
-H 'Content-Type: application/json' \
-d '{"role": "editor"}'
becomes:
import axios from 'axios';
const response = await axios({
url: '/users/7',
method: 'patch',
baseURL: 'https://api.example.com',
headers: {
'Content-Type': 'application/json',
},
data: {
"role": "editor"
},
});