Asked 25 days ago
27 Dec 2017
Views 74
kord

kord posted

react native error : Body not allowed for GET or HEAD requests


fetch("http://test.com/login.php",{
	 method  : 'GET',
		header : {
		 Accept  : 'application/json',
		'Content-Type' : 'application/json'
		},
		body :  JSON.stringify ({
		username : 'avc',
		password : 'ajad'
		})
		}). 	.done();


 node_modules\react-native\Libraries\Core\ExceptionsManager.js:65 Body not allowed for GET or HEAD requests


Mitul Dabhi

Mitul Dabhi
answered Jan 21 '18 20:17

You need to change GET method to POST . Because body only need with POST method.

suggested code is

fetch("http://test.com/login.php",{
	 method  : 'GET',
		header : {
		 Accept  : 'application/json',
		'Content-Type' : 'application/json'
		} 
		}). 	.done();


or change methed : "POST"


fetch("http://test.com/login.php",{
	 method  : 'POST',
		header : {
		 Accept  : 'application/json',
		'Content-Type' : 'application/json'
		},
		body :  JSON.stringify ({
		username : 'avc',
		password : 'ajad'
		})
		}). 	.done();
Edit Answer
Share
Post Answer