2.0.1 • Published 4 years ago

mini-program-proxy-js v2.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

What is this?

Proxy for mini-programs to make PUT and DELETE calls with docker proxy that can be found at https://github.com/Fastcomm/mini-program-proxy-elixir or https://github.com/Fastcomm/mini-program-proxy-ruby

Installation

npm i mini-program-proxy-js --save

Then...

PUT example

   import * as miniProgramProxy from 'miniprogram-proxy-js'

   let requestObject = {
      serverUrl: 'http://localhost:4200',
      url: 'example/:id',
      data: {
         username: 'Test',
         password: 'Password'
      },
      method: 'PUT'
   }

   miniProgramProxy.request({requestObject,
      success: (res) => {
         console.log("response",res);
      },
      fail: (res) => {
         console.log("response", res);
      }
   })

Delete example

   import * as miniProgramProxy from 'miniprogram-proxy-js'

     let requestObject = {
      serverUrl: 'http://localhost:4200',
      url: 'example/:id',
      method: 'DELETE'
   }

   miniProgramProxy.request({requestObject,
      success: (res) => {
         console.log("response",res);
      },
      fail: (res) => {
         console.log("response", res);
      }
   })

Request Object Options

PropertyTypeRequiredDescription
serverUrlstringtrueTarget server host url
urlstringtrueApi url
methodstringfalseAccepted values: 'PUT' , 'GET', 'DELETE', 'POST' The default will be 'GET'
dataobjectfalseRequest parameters
dataTypestringfalseExpected format of the returned data. The following formats are supported: json, text, base64. The default format is json
headersobjectfalseRequest headers The default is {"content-type": "application/json"}

Response CallbackFn

Ensure you add success and fail callbacks functions to your parameters when calling the request function to handle the response.

Error codes

ErrorDescription
11No right to call the interface.
12Network error.
13Timeout.
14Decoding failure.
19Http error.
20Request stopped/service end traffic limit.
2.0.1

4 years ago

2.0.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago