PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 13, 2022

[FIXED] How to convert *any* cURL or node-fetch request into an Axios request?

 October 13, 2022     axios, curl, google-chrome, javascript, node.js     No comments   

Issue

I'd like to be able to copy any HTTP request from the Network tab in Chrome Developer Tools and resend it from within node.js code as an Axios request. (Have tried node-fetch but found Axios better in several important ways). However, Chrome only has the following options for copying requests: Copy as Powershell, Copy as fetch, Copy as node.js fetch, Copy as cURL (cmd), Copy as cURL (bash). It doesn't include an Axios option.

Have come across a couple of online tools that will convert cURL requests:

  • https://curl.trillworks.com/ <== converts from cURL with options for Ansible, Browser (fetch), Dart, Elixir, Go, JSON, Node.js (fetch), Node.js (request), MATLAB, PHP, Python, R, Rust or Strest
  • https://onlinedevtools.in/curl <== converts from cURL with a subset of the options above: Go, JSON, Node.js, PHP, Python, R, Rust or Strest

But unfortunately neither of these have an option for Axios. I also haven't been able to find an npm package that would do the conversion. It needs to be repeatable so not sure what the best option would be but it can't just be a manual conversion - grateful for any suggestions.


Solution

You can use postman and you can convert cURL to several languages.

  1. Import a cURL command enter image description here enter image description here enter image description here

  2. Open Code panel for the request enter image description here

  3. Here you can select any of the languages you want to convert. enter image description here



Answered By - Ever
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing