Changes
Page history
Update React Native App Tutorial
authored
Mar 28, 2022
by
Aaditya Prakash
Show whitespace changes
Inline
Side-by-side
React-Native-App-Tutorial.md
View page @
d8a58d4e
...
@@ -278,7 +278,57 @@ const styles = StyleSheet.create({
...
@@ -278,7 +278,57 @@ const styles = StyleSheet.create({
For this tutorial, we will work on the Timetable APIs provided by the University Servers.
For this tutorial, we will work on the Timetable APIs provided by the University Servers.
```
Firstly, we will create defaults settings for APIs in another file called api.js.
```
javascript
export
const
GETOptions
=
{
method
:
'
GET
'
,
headers
:
{
"
Accept
"
:
"
application/json;charset=utf-8
"
,
"
Accept-Encoding
"
:
"
gzip, deflate, br
"
,
"
Accept-Language
"
:
"
de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
"
,
"
Cache-Control
"
:
"
no-cache
"
,
'
Pragma
'
:
'
no-cache
'
,
'
Expires
'
:
0
,
}
};
export
const
GETOptionsByLanguage
=
(
languageCode
=
null
)
=>
{
let
acceptLanguage
=
"
de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
"
;
if
(
languageCode
)
{
if
(
languageCode
===
'
en
'
){
acceptLanguage
=
"
en-US;q=0.9,en;q=0.8,de-DE,de;q=0.7
"
;
}
else
if
(
languageCode
!==
'
de
'
)
{
acceptLanguage
=
languageCode
;
}
}
return
{
method
:
'
GET
'
,
headers
:
{
"
Accept
"
:
"
application/json;charset=utf-8
"
,
"
Accept-Encoding
"
:
"
gzip, deflate, br
"
,
"
Accept-Language
"
:
acceptLanguage
,
"
Cache-Control
"
:
"
no-cache
"
,
'
Pragma
'
:
'
no-cache
'
,
'
Expires
'
:
0
,
}
}
};
export
const
POSTOptions
=
{
method
:
'
POST
'
,
headers
:
{
'
Accept
'
:
'
application/json
'
,
'
Cache-Control
'
:
'
no-cache
'
},
cache
:
'
no-cache
'
,
};
export
const
ApiSettings
=
{
TimeTableV2
:
{
getCourses
:
'
/app/{university}/timetable/shortcode/{timetableCode}
'
}
}
```
javascript
import React from 'react';
import React from 'react';
import {
import {
View,
View,
...
...
...
...