Laravel API returns a meta tag with the json response
up vote
0
down vote
favorite
My api keeps returning this meta tag within my json response :
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
What I'm doing is creating a new user then send the access token and token info:
if (Auth::attempt(['email' => $user->email, 'password' => $request->password])) {
return Auth::user()->createToken('mobileUser', );
}
return response()->json(['error' => 'Invalid username or Password']);
The api works just fine but the response is wrong.. when theres an error, it doesn't send the meta tag.. I tried to make it like this
return response()->json(Auth::user()->createToken('mobileUser', ));
But I got the same result..
Any reason why I keep getting this?
json laravel api meta-tags jsonresponse
add a comment |
up vote
0
down vote
favorite
My api keeps returning this meta tag within my json response :
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
What I'm doing is creating a new user then send the access token and token info:
if (Auth::attempt(['email' => $user->email, 'password' => $request->password])) {
return Auth::user()->createToken('mobileUser', );
}
return response()->json(['error' => 'Invalid username or Password']);
The api works just fine but the response is wrong.. when theres an error, it doesn't send the meta tag.. I tried to make it like this
return response()->json(Auth::user()->createToken('mobileUser', ));
But I got the same result..
Any reason why I keep getting this?
json laravel api meta-tags jsonresponse
do you setAccept: application/json
in your request's header?
– Pourbahrami
Nov 19 at 13:09
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My api keeps returning this meta tag within my json response :
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
What I'm doing is creating a new user then send the access token and token info:
if (Auth::attempt(['email' => $user->email, 'password' => $request->password])) {
return Auth::user()->createToken('mobileUser', );
}
return response()->json(['error' => 'Invalid username or Password']);
The api works just fine but the response is wrong.. when theres an error, it doesn't send the meta tag.. I tried to make it like this
return response()->json(Auth::user()->createToken('mobileUser', ));
But I got the same result..
Any reason why I keep getting this?
json laravel api meta-tags jsonresponse
My api keeps returning this meta tag within my json response :
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256" />
What I'm doing is creating a new user then send the access token and token info:
if (Auth::attempt(['email' => $user->email, 'password' => $request->password])) {
return Auth::user()->createToken('mobileUser', );
}
return response()->json(['error' => 'Invalid username or Password']);
The api works just fine but the response is wrong.. when theres an error, it doesn't send the meta tag.. I tried to make it like this
return response()->json(Auth::user()->createToken('mobileUser', ));
But I got the same result..
Any reason why I keep getting this?
json laravel api meta-tags jsonresponse
json laravel api meta-tags jsonresponse
asked Nov 19 at 12:07
Kneegrows
1
1
do you setAccept: application/json
in your request's header?
– Pourbahrami
Nov 19 at 13:09
add a comment |
do you setAccept: application/json
in your request's header?
– Pourbahrami
Nov 19 at 13:09
do you set
Accept: application/json
in your request's header?– Pourbahrami
Nov 19 at 13:09
do you set
Accept: application/json
in your request's header?– Pourbahrami
Nov 19 at 13:09
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){
$user = Auth::user();
$success['token'] = $user->createToken(config('name'))->accessToken;
return response()->json(['success' => $success], $this->successStatus);
} else{
return response()->json(['error'=>'Unauthorised'], 401);
}
add a comment |
up vote
0
down vote
I found out that the SMS function was causing this tag to appear... You have to edit it like this :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "your_url_SMS_service_here");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
If you encounter this tag, there should be a function behind the return causing that. Look for it and fix it
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){
$user = Auth::user();
$success['token'] = $user->createToken(config('name'))->accessToken;
return response()->json(['success' => $success], $this->successStatus);
} else{
return response()->json(['error'=>'Unauthorised'], 401);
}
add a comment |
up vote
0
down vote
if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){
$user = Auth::user();
$success['token'] = $user->createToken(config('name'))->accessToken;
return response()->json(['success' => $success], $this->successStatus);
} else{
return response()->json(['error'=>'Unauthorised'], 401);
}
add a comment |
up vote
0
down vote
up vote
0
down vote
if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){
$user = Auth::user();
$success['token'] = $user->createToken(config('name'))->accessToken;
return response()->json(['success' => $success], $this->successStatus);
} else{
return response()->json(['error'=>'Unauthorised'], 401);
}
if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){
$user = Auth::user();
$success['token'] = $user->createToken(config('name'))->accessToken;
return response()->json(['success' => $success], $this->successStatus);
} else{
return response()->json(['error'=>'Unauthorised'], 401);
}
answered Nov 19 at 12:14
Usman Jdn
422113
422113
add a comment |
add a comment |
up vote
0
down vote
I found out that the SMS function was causing this tag to appear... You have to edit it like this :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "your_url_SMS_service_here");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
If you encounter this tag, there should be a function behind the return causing that. Look for it and fix it
add a comment |
up vote
0
down vote
I found out that the SMS function was causing this tag to appear... You have to edit it like this :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "your_url_SMS_service_here");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
If you encounter this tag, there should be a function behind the return causing that. Look for it and fix it
add a comment |
up vote
0
down vote
up vote
0
down vote
I found out that the SMS function was causing this tag to appear... You have to edit it like this :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "your_url_SMS_service_here");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
If you encounter this tag, there should be a function behind the return causing that. Look for it and fix it
I found out that the SMS function was causing this tag to appear... You have to edit it like this :
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "your_url_SMS_service_here");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
If you encounter this tag, there should be a function behind the return causing that. Look for it and fix it
answered Nov 19 at 12:24
Kneegrows
1
1
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374315%2flaravel-api-returns-a-meta-tag-with-the-json-response%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
do you set
Accept: application/json
in your request's header?– Pourbahrami
Nov 19 at 13:09