Hi,
I have a problem to fetch data from a Server in my local network.
I have in the last few days gegoggelt much to the topic CORS and much on the subject of HTTP protocol .
I read a lot , write some test code but found no solution.
Situation:
php file on server:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Banano Code to fetch the data:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
1) if I start the APP direct from server....everything is ok
2) if i start the APP on my computer from file, i get a "CORS" error.
if i follow the link in the error massage i get the data.
3) if i add
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
    i get no "CORS" error but:
    
with postman i get the data without problem.
at the moment i feel walking through a forest
any help is welcome
best regards
Michael
			
			I have a problem to fetch data from a Server in my local network.
I have in the last few days gegoggelt much to the topic CORS and much on the subject of HTTP protocol .
I read a lot , write some test code but found no solution.
Situation:
php file on server:
			
				PHP:
			
		
		
		<?php
header("Content-type:application/json");
$age = array("Peter"=>35, "Ben"=>37, "Joe"=>43);
echo json_encode($age);
?>Banano Code to fetch the data:
			
				B4X:
			
		
		
		Dim fetch2Options As BANanoFetchOptions
     fetch2Options.Initialize
     fetch2Options.Mode = "no-cors"
    'fetch2Options.Headers = CreateMap("Content-type": "application/json; charset=UTF-8")
'
    Dim fetch1 As BANanoFetch
    'fetch1.Initialize("http://192.168.2.115/test.php",fetch2Options)
    fetch1.Initialize("http://192.168.2.115/test.php",Null)
    'fetch1.Initialize("https://jsonplaceholder.typicode.com/posts", Null)
    fetch1.Then(response)
'    ' we got a response, but as the Json() method returns a Promise, we will need to process it in the next 'then' so we return it to this Fetch
    fetch1.Return(response.Json)
    
    fetch1.Then(data)
'    ' the Json promise is resolved, lets log it...
    Log(data)1) if I start the APP direct from server....everything is ok
2) if i start the APP on my computer from file, i get a "CORS" error.
if i follow the link in the error massage i get the data.
3) if i add
			
				B4X:
			
		
		
		fetch2Options.Mode = "no-cors"Uncaught (in promise) SyntaxError: Unexpected end of input at app.js:42
// [59] fetch1.Return(response.Json)
return _response.json();
with postman i get the data without problem.
at the moment i feel walking through a forest
any help is welcome
best regards
Michael
 
				 
 
		