Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 710 Bytes

README.md

File metadata and controls

31 lines (24 loc) · 710 Bytes

web-curl-to-har

This is a plugin used on the browser side to convert curl commands into har objects

usage

import webCurlToHar, { setConfig } from 'web-curl-to-har';

if (isElectron()) {
  if (process.env.NODE_ENV === 'development') {
    setConfig('./');
  } else {
    setConfig(window?.path.join(window.__dirname, './build/'));
  }
} else {
  setConfig('./');
}

const handleCurl2Har=()=>{
      const curl= `curl 'http://www.apipost.cn/' `
      const curlData = webCurlToHar(curl);
      console.log(curlData);
}


/*
logs:
[{"request":{"method":"GET","url":"http://www.apipost.cn/","httpVersion":"HTTP/1.1","cookies":[],"headers":[],"queryString":[],"headersSize":-1,"bodySize":-1}}]
*/