mirror of
https://gitlab.com/wheres-the-tp/ui-mobile.git
synced 2026-01-25 09:34:56 -06:00
send auth with image upload request
This commit is contained in:
parent
845c227fc8
commit
8eeed01a07
2 changed files with 14 additions and 3 deletions
|
|
@ -33,3 +33,13 @@ export const fetchRequest = async ({
|
|||
|
||||
return res.json();
|
||||
};
|
||||
|
||||
export const fetchRequestBinary = async ({ endpoint, body }: { endpoint: string, body: any }) => {
|
||||
return fetch(`http://${BASE_URL}${endpoint}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...AuthManager.getAuthHeader(),
|
||||
},
|
||||
body,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
import { memoize } from 'ramda';
|
||||
import FilterRecord from '../records/FilterRecord';
|
||||
import FoodItemRecord from '../records/FoodItemRecord';
|
||||
import { fetchRequest } from './FetchApi';
|
||||
import { fetchRequest, fetchRequestBinary } from './FetchApi';
|
||||
import ImageResizer from 'react-native-image-resizer';
|
||||
import { BASE_URL } from '../constants/AppConstants';
|
||||
import AuthManager from '../AuthManager';
|
||||
|
||||
const IMAGE_HEIGHT = 600;
|
||||
const IMAGE_WIDTH = 800;
|
||||
|
|
@ -100,8 +101,8 @@ export const addImage = async ({
|
|||
name: 'photo.png',
|
||||
});
|
||||
|
||||
return fetch(`http://${BASE_URL}/addimage/${foodItemId}`, {
|
||||
method: 'POST',
|
||||
return fetchRequestBinary({
|
||||
endpoint: `/addimage/${foodItemId}`,
|
||||
body,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue