-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
63 lines (53 loc) · 1.46 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Sample React Native App - Superagent integration
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import { DataDome, DataDomeInterceptor, DataDomeModal } from '@datadome/datadome-superagent';
import {CLIENT_KEY} from '@env';
import {View, Button} from 'react-native';
const superagent = require('superagent');
const agent = superagent.agent();
agent
.use(DataDomeInterceptor.requestInterceptor)
.use(DataDomeInterceptor.responseInterceptor)
const makeMultipleRequests = () => {
for (var i=0; i<5; i++) {
makeRequest()
}
}
const makeRequest = () => {
agent
.get('https://datashield.co/')
.set('User-Agent', 'BLOCKUA')
.set('accept', 'application/json')
.then((res, err) => {
// Calling the end function will send the request
console.log("Got error", err)
console.log("Got response code", res.status)
})
.catch((err) => {console.log("Error from request", err)});
}
export default class App extends React.Component {
constructor(props) {
super(props);
DataDome.getInstance().setSdkKey(CLIENT_KEY);
}
render() {
return (
<View style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}}>
<DataDomeModal onRef={ref => (DataDome.getInstance().setContainerViewRef(ref))} />
<Button
title='Press me'
onPress={() => makeMultipleRequests()}/>
</View>
);
}
}