0

I'm returning an object from an API(Amazon MWS) call. I am able to pass this data to a vue instance within the same php file as a prop and display the results. Although this is just for test purposes and isn't very flexible.

What is the best way to handle a situation like this? Should I store the data from this object to a database, make a call from the vue instance to the database? If so how do I go about this? If not what are the best alternatives to handle passing data from an API call?

Thanks!

1 Answer 1

1

Create an API that sits in front of their API. Return what you want from your API after making a call to their API.

public function getProduct($pid)
{
    $product = $this->mwsservice->getProduct($pid);

    return response()->json($product);
}

Then call this function from vue when you want the data, make sure you have a Laravel route setup for it.

Sign up to request clarification or add additional context in comments.

3 Comments

Here to save the day again. So create a controller to pull in the data, then another method to pass the data to the vue instance through a http call like "Route::post('/posts', 'PostController@store');" ?
@Pyreal Yeah, that would be my recommendation to you.
You should also setup a function that would transform the data received from the external API so in the event it properties changes you can make the change in one place (e.g. your controller).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.