Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help in calling the Calorie Mama API in React Native #2

Open
SpeedyJeremy opened this issue Dec 15, 2022 · 0 comments
Open

Need help in calling the Calorie Mama API in React Native #2

SpeedyJeremy opened this issue Dec 15, 2022 · 0 comments

Comments

@SpeedyJeremy
Copy link

Hi all, I'm currently facing an issue of accessing the Calorie Mama API which I could not solve for a few days straight. This is my final year project and it means a lot to me if anyone would be able to help me out on this matter.

Here's my code to access the API:
` const photo = await camera.current.takeSnapshot({
quality: 70
});
// For sending image to Calorie Mama API!!!
const file = await fs.readFile(photo.path, "base64");
const data = decode(file);

    try {
        const response = await fetch("https://api.caloriemama.ai/v1/foodrecognition", {
            method: "POST",
            headers: {
                "Content-Type": "image/jpeg",
                "Authorization": "OAuth " + USER_KEY
            },
            body: {
                file: data
            }
        });
        console.log(response);
    }
    catch(e) {
        console.error(e);
    }`

I keep getting the status code of "401" which is actually a "bad authorization" problem based on the Calorie Mama documentation.
Really need some help on this! Will be grateful if anyone could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant