Asked 6 years ago
27 Dec 2017
Views 11576
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 Nov 30 '-1 00:00

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();
Post Answer