Ola
I have this axios call, but I would like to write it using the BANanoFetch.
I thank you.
PS: This is my attempt and I cant get it to work and return results
I have this axios call, but I would like to write it using the BANanoFetch.
B4X:
let response = await axios.get("https://api.edamam.com/search", {
params: {
q: plan,
app_id: '5b6623d5',
app_key: '46674aa2193dbb7b88ffd897331e661a',
from: 0,
to: 9
}
});
I thank you.
PS: This is my attempt and I cant get it to work and return results
B4X:
Dim Response As BANanoFetchResponse
Dim Data As BANanoJSONParser
Dim Error As BANanoJSONParser
Dim options As BANanoFetchOptions
options.Initialize
Dim params As Map = CreateMap()
params.put("q", plan)
params.Put("app_id", "5b6623d5")
params.put("app_key", "46674aa2193dbb7b88ffd897331e661a")
params.put("from", 0)
params.put("to", 9)
options.Body = BANano.ToJson(params)
options.Mode = "no-cors"
'options.Headers = CreateMap("Content-type": "application/json; charset=UTF-8")
'options.Headers = CreateMap("Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "*")
' list (GET is default, and we do not need extra options so we pass Null for the options)
Dim fetch1 As BANanoFetch
'execute the fetch
fetch1.Initialize("https://api.edamam.com/search", options)
'we got a promise response
fetch1.Then(Response)
' so resolve it to a json
fetch1.Return(Response.Json)
fetch1.Then(Data)
'Dim res As Map = Data.NextObject
Log(Data)
fetch1.Else(Error)
fetch1.Finally
fetch1.End