change to query param
This commit is contained in:
parent
e9603026bf
commit
8f09e50172
2 changed files with 30 additions and 8 deletions
|
|
@ -65,8 +65,12 @@ export class ToppingService {
|
||||||
country = getCountryMapSwitcher(asyncCountry);
|
country = getCountryMapSwitcher(asyncCountry);
|
||||||
|
|
||||||
return this._httpClient.get<ToppingGroup[]>(
|
return this._httpClient.get<ToppingGroup[]>(
|
||||||
`${environment.api}/toppings/groups/${country}/${filename}`,
|
`${environment.api}/toppings/groups`,
|
||||||
{
|
{
|
||||||
|
params: {
|
||||||
|
country: country,
|
||||||
|
filename: filename,
|
||||||
|
},
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -81,8 +85,12 @@ export class ToppingService {
|
||||||
country = getCountryMapSwitcher(asyncCountry);
|
country = getCountryMapSwitcher(asyncCountry);
|
||||||
|
|
||||||
return this._httpClient.get<ToppingList[]>(
|
return this._httpClient.get<ToppingList[]>(
|
||||||
`${environment.api}/toppings/lists/${country}/${filename}`,
|
`${environment.api}/toppings/lists`,
|
||||||
{
|
{
|
||||||
|
params: {
|
||||||
|
country: country,
|
||||||
|
filename: filename,
|
||||||
|
},
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package routers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"recipe-manager/data"
|
"recipe-manager/data"
|
||||||
"recipe-manager/services/logger"
|
"recipe-manager/services/logger"
|
||||||
|
|
@ -25,9 +26,15 @@ func NewToppingRouter(data *data.Data, taoLogger *logger.TaoLogger) *ToppingRout
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tr *ToppingRouter) Route(r chi.Router) {
|
func (tr *ToppingRouter) Route(r chi.Router) {
|
||||||
|
|
||||||
|
// check incoming request
|
||||||
|
fmt.Println("topping router", r.Routes())
|
||||||
|
|
||||||
r.Route("/toppings", func(r chi.Router) {
|
r.Route("/toppings", func(r chi.Router) {
|
||||||
r.Get("/groups/{country}/{filename}", tr.GetToppingGroups)
|
|
||||||
r.Get("/lists/{country}/{filename}", tr.GetToppingLists)
|
r.Get("/groups", tr.GetToppingGroups)
|
||||||
|
|
||||||
|
r.Get("/lists", tr.GetToppingLists)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -36,8 +43,13 @@ func (tr *ToppingRouter) GetToppingGroups(w http.ResponseWriter, r *http.Request
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
|
|
||||||
// just in case: params country and filename
|
// just in case: params country and filename
|
||||||
country := chi.URLParam(r, "country")
|
// country := chi.URLParam(r, "country")
|
||||||
filename := chi.URLParam(r, "filename")
|
// filename := chi.URLParam(r, "filename")
|
||||||
|
|
||||||
|
query := r.URL.Query()
|
||||||
|
|
||||||
|
country := query.Get("country")
|
||||||
|
filename := query.Get("filename")
|
||||||
|
|
||||||
// get topping groups
|
// get topping groups
|
||||||
toppingGroups := tr.data.GetAllToppingGroups(country, filename)
|
toppingGroups := tr.data.GetAllToppingGroups(country, filename)
|
||||||
|
|
@ -55,8 +67,10 @@ func (tr *ToppingRouter) GetToppingGroups(w http.ResponseWriter, r *http.Request
|
||||||
func (tr *ToppingRouter) GetToppingLists(w http.ResponseWriter, r *http.Request) {
|
func (tr *ToppingRouter) GetToppingLists(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
|
|
||||||
country := chi.URLParam(r, "country")
|
query := r.URL.Query()
|
||||||
filename := chi.URLParam(r, "filename")
|
|
||||||
|
country := query.Get("country")
|
||||||
|
filename := query.Get("filename")
|
||||||
|
|
||||||
// get toppping list
|
// get toppping list
|
||||||
toppingLists := tr.data.GetToppingsList(country, filename)
|
toppingLists := tr.data.GetToppingsList(country, filename)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue