Revert "fix(headless): use fetch instead of axios for auth"
This reverts commit 09ea8cd563
.
This commit is contained in:
parent
0ac28515df
commit
7ab708a536
1 changed files with 23 additions and 31 deletions
|
@ -11,26 +11,22 @@ import {
|
||||||
|
|
||||||
import { getDeviceUuid } from "./deviceUuid";
|
import { getDeviceUuid } from "./deviceUuid";
|
||||||
|
|
||||||
// to support refresh auth in headless mode we'll use fetch instead of apollo/axios
|
// to support refresh auth in headless mode we'll use axios instead of apollo
|
||||||
// read more https://github.com/transistorsoft/react-native-background-fetch/issues/562
|
// read more https://github.com/transistorsoft/react-native-background-fetch/issues/562
|
||||||
|
|
||||||
export async function registerUser() {
|
export async function registerUser() {
|
||||||
const response = await fetch(env.GRAPHQL_URL, {
|
const { data } = await network.axios.post(
|
||||||
method: "POST",
|
env.GRAPHQL_URL,
|
||||||
headers: {
|
{
|
||||||
"Content-Type": "application/json",
|
|
||||||
// No Authorization header for this request
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
query: REGISTER_USER_MUTATION_STRING,
|
query: REGISTER_USER_MUTATION_STRING,
|
||||||
}),
|
},
|
||||||
});
|
{
|
||||||
|
headers: {
|
||||||
if (!response.ok) {
|
// Skip adding Authorization header for this request
|
||||||
throw new Error(`HTTP Error: ${response.status} ${response.statusText}`);
|
Authorization: undefined,
|
||||||
}
|
},
|
||||||
|
},
|
||||||
const data = await response.json();
|
);
|
||||||
|
|
||||||
if (data.errors && data.errors.length > 0) {
|
if (data.errors && data.errors.length > 0) {
|
||||||
const message = data.errors.map((err) => err.message).join("; ");
|
const message = data.errors.map((err) => err.message).join("; ");
|
||||||
|
@ -43,27 +39,23 @@ export async function registerUser() {
|
||||||
|
|
||||||
export async function loginUserToken({ authToken }) {
|
export async function loginUserToken({ authToken }) {
|
||||||
const deviceUuid = await getDeviceUuid();
|
const deviceUuid = await getDeviceUuid();
|
||||||
const response = await fetch(env.GRAPHQL_URL, {
|
const { data } = await network.axios.post(
|
||||||
method: "POST",
|
env.GRAPHQL_URL,
|
||||||
headers: {
|
{
|
||||||
"Content-Type": "application/json",
|
|
||||||
// No Authorization header for this request
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
query: LOGIN_USER_TOKEN_MUTATION_STRING,
|
query: LOGIN_USER_TOKEN_MUTATION_STRING,
|
||||||
variables: {
|
variables: {
|
||||||
authTokenJwt: authToken,
|
authTokenJwt: authToken,
|
||||||
phoneModel: Device.modelName,
|
phoneModel: Device.modelName,
|
||||||
deviceUuid,
|
deviceUuid,
|
||||||
},
|
},
|
||||||
}),
|
},
|
||||||
});
|
{
|
||||||
|
headers: {
|
||||||
if (!response.ok) {
|
// Skip adding Authorization header for this request
|
||||||
throw new Error(`HTTP Error: ${response.status} ${response.statusText}`);
|
Authorization: undefined,
|
||||||
}
|
},
|
||||||
|
},
|
||||||
const data = await response.json();
|
);
|
||||||
|
|
||||||
if (data.errors && data.errors.length > 0) {
|
if (data.errors && data.errors.length > 0) {
|
||||||
const message = data.errors.map((err) => err.message).join("; ");
|
const message = data.errors.map((err) => err.message).join("; ");
|
||||||
|
|
Loading…
Add table
Reference in a new issue