So i call the function like this under construction brackets.
constructor()
{
userData.getUserBySignature(this.userDetails.api_signature);
}
user-data.ts
getUserBySignature(api_signature:any)
{
const url = this.appData.getApiUrl() + 'getUserBySignature';
const data = this.jsonToURLEncoded({
api_signature: api_signature
});
return this.http.post(url, data, { headers: this.options });
}
php function
function getUserBySignature()
{
$request = \Slim\Slim::getInstance()->request();
$api_signature = $request->post('api_signature');
$db = getDB();
$sql = "SELECT api_signature, uid,username,name,first_name,last_name,bio,artisticBehaviour,location,email,profile_pic,profile_bg,updates_count,friend_count,profile_views,group_count,emailNotifications FROM users WHERE api_signature=:api_signature";
$stmt = $db->prepare($sql);
$stmt->bindParam("api_signature", $api_signature, PDO::PARAM_STR);
$stmt->execute();
$userDetails = $stmt->fetch(PDO::FETCH_OBJ); //this one?
if (!empty($userDetails)) {
return $userDetails;
} else {
$data['error'] = 'Invalid API signature33' . $api_signature;
echo json_encode($data);
exit;
}
}
}
but it doesnt work. i am getting 'Invalid API signature33' . $api_signature; without the $api_signature.
Any idea how to do that?
Need to inject the service to the constructor first and then subscribe to the observable to resolve data
constructor(private userData: userData)
{
userData.getUserBySignature(this.userDetails.api_signature).subscribe((data)=> {
console.log(data) // should return the data
});
}
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Slim is, as its name suggests, a micro-framework that is compact and fast. The reason for its such characteristics lies in the fact that it is completely independent of third-party code. It was created in 2010, at the moment its most recent version is 4.5.0.
https://www.slimframework.com/
Angular is one of the most powerful JavaScript frameworks out there. Google uses this platform to develop a Single Page Application (SPA). This development environment is known primarily because it provides developers with a better environment for combining JavaScript with HTML and CSS. More than half a million sites like google.com, youtube.com, etc. use Angular.
https://angular.io/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.