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

react-native-http-bridge

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-http-bridge - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

2

package.json
{
"name": "react-native-http-bridge",
"version": "0.4.1",
"version": "0.5.0",
"description": "A simple HTTP debug server for React Native apps",

@@ -5,0 +5,0 @@ "main": "httpServer.js",

# react-native-http-bridge
HTTP Server for [React Native](https://github.com/facebook/react-native)
Simple HTTP server for [React Native](https://github.com/facebook/react-native)
Supports only POST-requests and one-way communication. Created for [Status.im](https://github.com/status-im)
Since 0.5.0 supports and handles GET, POST, PUT and DELETE requests.
The library can be useful for handling requests with `application/json` content type
(and this is the only content type we support at the current stage) and returning different responses.
Created for [Status.im](https://github.com/status-im/status-react).
## Install

@@ -32,16 +36,18 @@

Initalise the server in the `componentWillMount` lifecycle method. You need to provide a `port` and a callback where requests will be captured. Currently there is no way to return responses.
Initalize the server in the `componentWillMount` lifecycle method. You need to provide a `port` and a callback.
```js
componentWillMount(){
componentWillMount() {
// initalize the server (now accessible via localhost:1234)
httpBridge.start(5561, function(request) {
// request.url
// request.postData
// you can use request.url, request.type and request.postData here
if (request.type === "GET" && request.url.split("/")[1] === "users") {
httpBridge.respond(200, "application/json", "{\"message\": \"OK\"}");
} else {
httpBridge.respond(400, "application/json", "{\"message\": \"Bad Request\"}");
}
});
}

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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