Handle HTTP auth for API calls
This commit is contained in:
parent
9813796a5d
commit
9bbac3b99e
@ -29,21 +29,22 @@ function _postProcessRecipes(response) {
|
||||
|
||||
|
||||
export function loadRecipes() {
|
||||
return fetch(`${constants.API_URL}api/v1/recipes`)
|
||||
return fetch(`${constants.API_URL}api/v1/recipes`, { credentials: 'same-origin' })
|
||||
.then(_postProcessRecipes);
|
||||
}
|
||||
|
||||
|
||||
export function loadRecipe(id) {
|
||||
return fetch(`${constants.API_URL}api/v1/recipe/${id}`)
|
||||
return fetch(`${constants.API_URL}api/v1/recipe/${id}`, { credentials: 'same-origin' })
|
||||
.then(_postProcessRecipes);
|
||||
}
|
||||
|
||||
|
||||
export function refetchRecipe(id) {
|
||||
return fetch(`${constants.API_URL}api/v1/recipe/${id}/refetch`, {
|
||||
method: 'GET',
|
||||
})
|
||||
return fetch(
|
||||
`${constants.API_URL}api/v1/recipe/${id}/refetch`,
|
||||
{ credentials: 'same-origin' },
|
||||
)
|
||||
.then(_postProcessRecipes);
|
||||
}
|
||||
|
||||
@ -52,6 +53,7 @@ export function postRecipeByUrl(recipe) {
|
||||
return fetch(`${constants.API_URL}api/v1/recipes/by_url`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(recipe),
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
.then(_postProcessRecipes);
|
||||
}
|
||||
@ -61,6 +63,7 @@ export function postRecipeManually(recipe) {
|
||||
return fetch(`${constants.API_URL}api/v1/recipes/manually`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(recipe),
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
.then(_postProcessRecipes);
|
||||
}
|
||||
@ -70,6 +73,7 @@ export function editRecipe(id, recipe) {
|
||||
return fetch(`${constants.API_URL}api/v1/recipe/${id}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(recipe),
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
.then(_postProcessRecipes);
|
||||
}
|
||||
@ -78,5 +82,6 @@ export function editRecipe(id, recipe) {
|
||||
export function deleteRecipe(id) {
|
||||
return fetch(`${constants.API_URL}api/v1/recipe/${id}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'same-origin',
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user