anthonygauthier / axios-curlirize

axios plugin converting requests to cURL commands, saving and logging them.
MIT License
186 stars 31 forks source link

Feature request: axios request to curl command #33

Open andrisi opened 4 years ago

andrisi commented 4 years ago

Would be useful if ther would be a utility method exposed that translates an axios request without running it. So not intercepting the axios request, just doing the translation, and from the request passed in, not the normalised/extended version that the interceptor gets. Thanks a million, it's great to see if someone provides a solution to an issue one has - even without this extra feature I described.

eran10 commented 3 years ago

+1

F-loat commented 4 months ago

A simple workaround

import axios from 'axios';
import curlirize from 'axios-curlirize';

const request = axios.create({
  adapter: config => Promise.resolve({ config })
})

curlirize(request);

request
  .post('http://localhost:7500/', { dummy: 'data' }, {
    curlirize: false
  })
  .then(res => {
    console.log(res.config.curlCommand);
  })