sketch-request
v1.0.1
Published
request module for sketch plugin
Downloads
6
Readme
Sketch Request
A request module for sketch plugin
Install
npm install sketch-request -S
Usage
const request = require('sketch-request')
request(url, options)
Options
- method {String} GET/POST http re
- body {String} POST body
- headers {Object} request headers
- args {Object} POST FormData
- files {String} path to the upload file
Example
Upload Image
const request = require('sketch-request')
request('https://test.oss-cn-hangzhou.aliyuncs.com/',{
method: "post",
headers: {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
},
args: {
id: 1000
},
files: {
file: '/Users/zobor/1.png'
}
}).then(rs=>{
console.log(rs.json())
})
Post Data
const request = require('sketch-request')
request('https://test.oss-cn-hangzhou.aliyuncs.com/',{
method: "post",
headers: {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
},
body: JSON.stringify({
username: 'zobor',
password: '123456'
}),
}).then(rs=>{
console.log(rs.json())
})