bounswe / 2021SpringGroup5

4 stars 4 forks source link

Connect event detail page to backend #685

Closed umutgun17 closed 2 years ago

umutgun17 commented 2 years ago

I will integrate the event page with backend I will communicate with the backend team I will communicate with the Didem about auth (authantication token)

umutgun17 commented 2 years ago

There are CORS and HTTPS problem.

The frontend responses as a HTTPS whereas the backend responses ad a HTTP so we cannot request post from HTTPS to HTTP client.

umutgun17 commented 2 years ago

CORS problem was solved by backend team

umutgun17 commented 2 years ago

I communicated with Didem to use Auth.

I need it to recognize me by backend. It basically means that there is a token on header and all post method has that token. Therefore, backend understand which user send the post.

umutgun17 commented 2 years ago

I learned axios and examples code.

umutgun17 commented 2 years ago

I integrated the event detail page with the backend API.

The simple code is below.


export function getEvent(me, event_id) {

  return httpClient
    .post(`/post/get_event_post_details/`, {
      '@context': 'https://www.w3.org/ns/activitystreams',
      summary: `${me.name} is reading an event post.`,
      type: 'View',

      actor: {
        type: 'Person',
        name: `${me.name}`,
        surname: `${me.surname}`,
        username: `${me.username}`,
        Id: Number.parseInt(me.Id),
      },

      object: {
        type: 'EventPost',
        post_id: Number.parseInt(event_id),
      },

    })
    .then(res => res.data);

}