Skip to content

http相关

javascript
const core = require('cheese-js');
lua
local core = require('cheese-lua')

get请求:public get(): http

用法示例:

javascript
const http = new core.http;
let body = http.builder().url("https://www.baidu.com").get().sync()
console.log(body)
lua
local http = core.http.new()
local body = http:builder():url("https://www.baidu.com"):get():sync()
print(body)

get请求:public post: http

用法示例:

javascript
const http = new core.http;
let body = http.builder().url("https://www.baidu.com").post().sync()
console.log(body)
lua
local http = core.http.new()
local body = http:builder():url("https://www.baidu.com"):post():sync()
print(body)

图鉴打码示例:

javascript
const core = require("cheese-js");
let http = new core.http()
let converters =  core.converters
let builder =http.builder()
builder.url("http://api.ttshitu.com/predict")
builder.addParam("username","333")
builder.addParam("password","333")
builder.addParam("typeid","1001")
builder.addParam("image",converters.bitmapToBase64(converters.assetsToBitmap("img.png") ))
builder.post(false)
console.log(builder.sync())
lua
local core = require('cheese-lua')
local http = core.http.new()
local converters = core.converters
local builder = http:builder()
builder:url("http://api.ttshitu.com/predict")
builder:addParam("username","333")
builder:addParam("password","333")
builder:addParam("typeid","1001")
builder:addParam("image", converters.bitmapToBase64(converters.assetsToBitmap("img.png")))
builder:post(false)
print(builder:sync())

Released under the GPL-3.0 License.