sei-ec-remote / project-4-issues

Open an issue to receive help on project 4
0 stars 0 forks source link

Authentication Error #263

Closed JordonM closed 12 months ago

JordonM commented 12 months ago

What stack are you using?

(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)

MERN

What's the problem you're trying to solve?

Having an error getting to the API

Post any code you think might be relevant (one fenced block per file)

import apiUrl from '../apiConfig'
import axios from 'axios'

export const getAllEmployees = () => {
    return axios(`${apiUrl}/employees`)
}

export const getOneEmployee = (id) => {
    return axios(`${apiUrl}/employees/${id}`)
}

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

image image image

What is your best guess as to the source of the problem?

My API is being sending back the employee info back to the client.

What things have you already tried to solve the problem?

I checked Postman and it works fine on there.

Paste a link to your repository here https://github.com/JordonM/EmployeeAPP/tree/main https://github.com/JordonM/EmployerExpAPI/tree/main

timmshinbone commented 12 months ago

Share a screenshot of the postman authorization section, and a screenshot of the route in the backend

JordonM commented 12 months ago

image image

timmshinbone commented 12 months ago

So, that's a protected route, which means you need to use an authorization header, similar to how we do in createPet in the pets app