Now when searching a loggedinuser header element is passed also.
This commit is contained in:
@@ -10,6 +10,7 @@ import URI from 'urijs';
|
|||||||
import InfiniteScroll from 'react-infinite-scroller';
|
import InfiniteScroll from 'react-infinite-scroller';
|
||||||
|
|
||||||
import { fetchJSON } from './http.jsx';
|
import { fetchJSON } from './http.jsx';
|
||||||
|
import { getCookie } from './Cookie.jsx';
|
||||||
|
|
||||||
var MediaQuery = require('react-responsive');
|
var MediaQuery = require('react-responsive');
|
||||||
|
|
||||||
@@ -105,11 +106,18 @@ class SearchRequest extends React.Component {
|
|||||||
// Test this by calling missing endpoint or 404 query and see what code
|
// Test this by calling missing endpoint or 404 query and see what code
|
||||||
// and filter the error message based on the code.
|
// and filter the error message based on the code.
|
||||||
// Calls a uri and returns the response as json
|
// Calls a uri and returns the response as json
|
||||||
callURI(uri) {
|
callURI(uri, method, data={}) {
|
||||||
return fetch(uri)
|
return fetch(uri, {
|
||||||
|
method: method,
|
||||||
|
headers: new Headers({
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'authorization': getCookie('token'),
|
||||||
|
'loggedinuser': getCookie('loggedInUser'),
|
||||||
|
})
|
||||||
|
})
|
||||||
.then(response => { return response })
|
.then(response => { return response })
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
throw Error('Something went wrong while fetching URI.');
|
throw Error(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +136,7 @@ class SearchRequest extends React.Component {
|
|||||||
// this.writeLoading();
|
// this.writeLoading();
|
||||||
|
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(() => this.callURI(uri))
|
.then(() => this.callURI(uri, 'GET'))
|
||||||
.then(response => {
|
.then(response => {
|
||||||
// If we get a error code for the request
|
// If we get a error code for the request
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -174,8 +182,8 @@ class SearchRequest extends React.Component {
|
|||||||
console.log('CallSearchFillMovieList: ', error)
|
console.log('CallSearchFillMovieList: ', error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error) => {
|
||||||
throw Error('Something went wrong when fetching query.')
|
console.log('Something went wrong when fetching query.', error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +192,7 @@ class SearchRequest extends React.Component {
|
|||||||
// this.writeLoading();
|
// this.writeLoading();
|
||||||
|
|
||||||
Promise.resolve()
|
Promise.resolve()
|
||||||
.then(() => this.callURI(uri))
|
.then(() => this.callURI(uri, 'GET', undefined))
|
||||||
.then(response => {
|
.then(response => {
|
||||||
// If we get a error code for the request
|
// If we get a error code for the request
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -217,8 +225,8 @@ class SearchRequest extends React.Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((error) => {
|
||||||
throw Error('Something went wrong when fetching query.')
|
console.log('Something went wrong when fetching query.', error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user