Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

httpsnippet

Package Overview
Dependencies
Maintainers
4
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpsnippet - npm Package Compare versions

Comparing version 1.21.0 to 1.22.0

src/targets/javascript/axios.js

3

package.json
{
"version": "1.21.0",
"version": "1.22.0",
"name": "httpsnippet",

@@ -23,2 +23,3 @@ "description": "HTTP Request snippet generator for *most* languages",

"jquery",
"kotlin",
"objc",

@@ -25,0 +26,0 @@ "objective-c",

@@ -245,2 +245,4 @@ 'use strict'

throw new Error('The supplied custom target client must have an `info` object with a `key` and `title` property.')
} else if (targets[target].hasOwnProperty(client.info.key)) {
throw new Error('The supplied custom target client already exists, please use a different key')
}

@@ -247,0 +249,0 @@

@@ -11,2 +11,3 @@ 'use strict'

javascript: require('./javascript'),
kotlin: require('./kotlin'),
node: require('./node'),

@@ -13,0 +14,0 @@ objc: require('./objc'),

@@ -47,3 +47,3 @@ /**

case 'multipart/form-data':
code.push('var form = new FormData();')
code.push('const form = new FormData();')

@@ -50,0 +50,0 @@ source.postData.params.forEach(function (param) {

@@ -13,3 +13,4 @@ 'use strict'

fetch: require('./fetch'),
xhr: require('./xhr')
xhr: require('./xhr'),
axios: require('./axios')
}

@@ -41,3 +41,3 @@ /**

case 'multipart/form-data':
code.push('var form = new FormData();')
code.push('const form = new FormData();')

@@ -66,3 +66,3 @@ source.postData.params.forEach(function (param) {

code.push('var settings = ' + JSON.stringify(settings, null, opts.indent).replace('"[form]"', 'form'))
code.push('const settings = ' + JSON.stringify(settings, null, opts.indent).replace('"[form]"', 'form') + ';')
.blank()

@@ -69,0 +69,0 @@ .push('$.ajax(settings).done(function (response) {')

@@ -25,3 +25,3 @@ /**

case 'application/json':
code.push('var data = JSON.stringify(%s);', JSON.stringify(source.postData.jsonObj, null, opts.indent))
code.push('const data = JSON.stringify(%s);', JSON.stringify(source.postData.jsonObj, null, opts.indent))
.push(null)

@@ -31,3 +31,3 @@ break

case 'multipart/form-data':
code.push('var data = new FormData();')
code.push('const data = new FormData();')

@@ -47,7 +47,7 @@ source.postData.params.forEach(function (param) {

default:
code.push('var data = %s;', JSON.stringify(source.postData.text || null))
code.push('const data = %s;', JSON.stringify(source.postData.text || null))
.blank()
}
code.push('var xhr = new XMLHttpRequest();')
code.push('const xhr = new XMLHttpRequest();')

@@ -54,0 +54,0 @@ if (opts.cors) {

@@ -13,3 +13,4 @@ 'use strict'

request: require('./request'),
unirest: require('./unirest')
unirest: require('./unirest'),
axios: require('./axios')
}

@@ -31,9 +31,9 @@ /**

code.push('var http = require("%s");', source.uriObj.protocol.replace(':', ''))
code.push('const http = require("%s");', source.uriObj.protocol.replace(':', ''))
code.blank()
.push('var options = %s;', JSON.stringify(reqOpts, null, opts.indent))
.push('const options = %s;', JSON.stringify(reqOpts, null, opts.indent))
.blank()
.push('var req = http.request(options, function (res) {')
.push(1, 'var chunks = [];')
.push('const req = http.request(options, function (res) {')
.push(1, 'const chunks = [];')
.blank()

@@ -45,3 +45,3 @@ .push(1, 'res.on("data", function (chunk) {')

.push(1, 'res.on("end", function () {')
.push(2, 'var body = Buffer.concat(chunks);')
.push(2, 'const body = Buffer.concat(chunks);')
.push(2, 'console.log(body.toString());')

@@ -55,3 +55,3 @@ .push(1, '});')

if (source.postData.paramsObj) {
code.unshift('var qs = require("querystring");')
code.unshift('const qs = require("querystring");')
code.push('req.write(qs.stringify(%s));', stringifyObject(source.postData.paramsObj, {

@@ -58,0 +58,0 @@ indent: ' ',

@@ -25,3 +25,3 @@ /**

code.push('var request = require("request");')
code.push("const request = require('request');")
.blank()

@@ -94,3 +94,3 @@

code.push('var jar = request.jar();')
code.push('const jar = request.jar();')

@@ -100,3 +100,3 @@ var url = source.url

source.cookies.forEach(function (cookie) {
code.push('jar.setCookie(request.cookie("%s=%s"), "%s");', encodeURIComponent(cookie.name), encodeURIComponent(cookie.value), url)
code.push("jar.setCookie(request.cookie('%s=%s'), '%s');", encodeURIComponent(cookie.name), encodeURIComponent(cookie.value), url)
})

@@ -107,6 +107,6 @@ code.blank()

if (includeFS) {
code.unshift('var fs = require("fs");')
code.unshift("const fs = require('fs');")
}
code.push('var options = %s;', stringifyObject(reqOpts, { indent: ' ', inlineCharacterLimit: 80 }))
code.push('const options = %s;', stringifyObject(reqOpts, { indent: ' ', inlineCharacterLimit: 80 }))
.blank()

@@ -113,0 +113,0 @@

@@ -23,9 +23,9 @@ /**

code.push('var unirest = require("unirest");')
code.push('const unirest = require("unirest");')
.blank()
.push('var req = unirest("%s", "%s");', source.method, source.url)
.push('const req = unirest("%s", "%s");', source.method, source.url)
.blank()
if (source.cookies.length) {
code.push('var CookieJar = unirest.jar();')
code.push('const CookieJar = unirest.jar();')

@@ -37,3 +37,3 @@ source.cookies.forEach(function (cookie) {

code.push('req.jar(CookieJar);')
.blank()
.blank()
}

@@ -55,2 +55,3 @@

code.push('req.form(%s);', JSON.stringify(source.postData.paramsObj, null, opts.indent))
.blank()
}

@@ -63,2 +64,3 @@ break

.push('req.send(%s);', JSON.stringify(source.postData.jsonObj, null, opts.indent))
.blank()
}

@@ -91,2 +93,3 @@ break

code.push('req.multipart(%s);', JSON.stringify(multipart, null, opts.indent))
.blank()
break

@@ -96,3 +99,4 @@

if (source.postData.text) {
code.push(opts.indent + 'req.send(%s);', JSON.stringify(source.postData.text, null, opts.indent))
code.push('req.send(%s);', JSON.stringify(source.postData.text, null, opts.indent))
.blank()
}

@@ -102,7 +106,6 @@ }

if (includeFS) {
code.unshift('var fs = require("fs");')
code.unshift('const fs = require("fs");')
}
code.blank()
.push('req.end(function (res) {')
code.push('req.end(function (res) {')
.push(1, 'if (res.error) throw new Error(res.error);')

@@ -109,0 +112,0 @@ .blank()

@@ -75,3 +75,3 @@ /**

code.push('curl_setopt_array($curl, array(')
code.push('curl_setopt_array($curl, [')

@@ -101,9 +101,9 @@ var curlopts = new CodeBuilder(opts.indent, '\n' + opts.indent)

if (headers.length) {
curlopts.push('CURLOPT_HTTPHEADER => array(')
curlopts.push('CURLOPT_HTTPHEADER => [')
.push(1, headers.join(',\n' + opts.indent + opts.indent))
.push('),')
.push('],')
}
code.push(1, curlopts.join())
.push('));')
.push(']);')
.blank()

@@ -110,0 +110,0 @@ .push('$response = curl_exec($curl);')

@@ -34,3 +34,3 @@ 'use strict'

result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ')'
result = '[\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ']'
break

@@ -45,3 +45,3 @@

}
result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ')'
result = '[\n' + indent + result.join(',\n' + indent) + '\n' + lastIndent + ']'
break

@@ -48,0 +48,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc