Laravel fetch post returns no data if the parameter is received in the background

Use fetch to send a request to the background, but the background can not receive the parameters passed in the past, showing that the received is null

Solution, add 'Content-Type': 'application / json' in the header information   

Complete code:

fetch(url, {
                method: 'POST',
                headers: {
                    'X-CSRF-TOKEN': "{{csrf_token()}}",
                    'Content-Type': 'application/json'
                },
                body:JSON.stringify(postData)
            })

 

Guess you like

Origin www.cnblogs.com/zqblog1314/p/12739934.html